<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/newQuotation.do"/>

<%
    String chipTracContext = "/" + ConfigManager.getChipTracContext();
    int i=0;
    int m=0;
    String selectedMethod = null;
    String selectedAccount = null;
    com.scalar.chiptrack.sales.forms.quote.QuotationForm quotationForm1 = null;
    int noOfDecimalsInAmount = ConfigManager.getnoOfDecmalsInAmount();
    String restrictCharsJSFnc = "javascript:restrictCharacters(this,7,"+noOfDecimalsInAmount+")";
    String restrictCharsJSFnc2 = "javascript:restrictCharacters(this,7,"+(noOfDecimalsInAmount>0?noOfDecimalsInAmount-1:0)+")";
    String restrictAmtJSFnc = "javascript:restrictAmt(this,7,"+noOfDecimalsInAmount+")";
%>

<%@page import="java.util.ArrayList,
                  com.scalar.chiptrack.utils.ConfigManager,
                  com.scalar.chiptrack.commons.SessionKeys,
                  com.scalar.chiptrack.commons.Constants,
                  com.scalar.chiptrack.users.User,
                  com.scalar.chiptrack.users.Functionality,
                  com.scalar.chiptrack.utils.StringUtils,
				  com.scalar.chiptrack.sales.CustomerPartNumber,
                java.util.HashMap,
                com.scalar.chiptrack.sales.ContactPerson,
                com.scalar.chiptrack.sales.forms.quote.QuotationForm,
                com.scalar.chiptrack.sales.Quotation" %>
<%@ page import="com.scalar.chiptrack.sales.LineItem" %>
<%@ page import="com.scalar.chiptrack.sales.actions.ChangeOrderAction" %>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>

<script language="JavaScript">
var prevPrice = 0;
function check()
{
    var pa1 = document.getElementById("newshippingMethod");
    var pa3 = document.getElementById("newshippingAccount");
    <% quotationForm1 = (QuotationForm)request.getAttribute("QuotationForm"); %>
    document.QuotationForm.shippingAddressId.value=<%=quotationForm1.getShippingAddressId()%>;
    <%
    String addShipMethod = request.getParameter("shipAccount1");
    if( addShipMethod == null || ( !addShipMethod.equals("-2") ) )
    {
    %>
          document.QuotationForm.newshippingMethod.style.visibility = "hidden";
          pa1.innerHTML = "";
          document.QuotationForm.newshippingAccount.style.visibility = "hidden";
          pa3.innerHTML = "";
    <%
    }
    if((addShipMethod!=null) && (!addShipMethod.trim().equals("")))
    {
    %>
        document.QuotationForm.shippingMethod.value = '<%=addShipMethod%>';
        document.QuotationForm.shipAccount1.value = '<%=addShipMethod%>';
     <%
    }
    %>
    if ( document.QuotationForm.shippingMethod.value == "" )
    {
        document.QuotationForm.shippingMethod.value = "-1";
    }
    var salesTaxType = document.QuotationForm.salesTaxType.value;
    <%
    String state1 = request.getParameter ( "newSalesState" );
    String value1 = request.getParameter ( "newSalesTax" );
    if( state1 != null && value1 != null )
    {
    %>
    if ( salesTaxType == "-1" )
    {
        addNewSalesTaxType( document.QuotationForm.salesTaxType );
        document.QuotationForm.newSalesState.value = '<%=state1%>';
        document.QuotationForm.newSalesTax.value = '<%=value1%>';
    }
    <%  }  %>
    var shippingLabel = document.getElementById("newShippingTerms");
    if( document.QuotationForm.shippingTerms.value == -2 )
    {
        document.QuotationForm.newShippingTerms.style.visibility = "visible";
        shippingLabel.innerHTML = "New Pay Terms : ";
    }
    else
    {
        document.QuotationForm.newShippingTerms.style.visibility = "hidden";
        shippingLabel.innerHTML = "";
    }
    var deliveryTermsLabel = document.getElementById("newDeliveryTerms");
    if( document.QuotationForm.deliveryTerms.value == -2 )
    {
        document.QuotationForm.newDeliveryTerms.style.visibility = "visible";
        deliveryTermsLabel.innerHTML = "New <bean:message key="label.sales.salesOrder.DeliveryTerms" /> : ";
    }
    else
    {
        document.QuotationForm.newDeliveryTerms.style.visibility = "hidden";
        deliveryTermsLabel.innerHTML = "";
    }
    var pa = document.getElementById("shippingInstructions");
    if ( document.QuotationForm.shippingInstructionsId.value == -2 )
    {
        pa.innerHTML = "New <bean:message key="label.sales.shippingInstructions" />"
        document.QuotationForm.shippingInstructions.readOnly = false;
    }
    else
    {
        pa.innerHTML = "<bean:message key="label.sales.shippingInstructions" />"
        document.QuotationForm.shippingInstructions.readOnly = true;
    }
    if( document.QuotationForm.contactPerson.value == '' )
    {
        document.QuotationForm.contactPerson.value = '';
        document.QuotationForm.phoneNumber.value = '';
        document.QuotationForm.cellNumber.value = '';
        document.QuotationForm.faxNumber.value = '';
        document.QuotationForm.email.value = '';

        document.QuotationForm.phoneNumber.disabled = true;
        document.QuotationForm.cellNumber.disabled = true;
        document.QuotationForm.faxNumber.disabled = true;
        document.QuotationForm.email.disabled = true;
    }
    showHideAddNewApplication();
    showHideNewEndUserField();
        var form = document.QuotationForm;
        var endCustomerCtrl = form.odmId;
        var newEndCustomerNameCtrl = form.newEndCustomerName;
        var endCustomerLabelSpan = document.getElementById ( "endCustomerLabelSpan" );
        var endCustomerTxfieldSpan = document.getElementById ( "endCustomerTxfieldSpan" );
        if ( endCustomerCtrl.value == "-2" )
        {
            endCustomerLabelSpan.style.display = 'block'
            endCustomerTxfieldSpan.style.display = 'block'
        }
        else
        {
            newEndCustomerNameCtrl.value = "";
            endCustomerLabelSpan.style.display = 'none'
            endCustomerTxfieldSpan.style.display = 'none'
        }
    showHideNewCustPartNo(-1);
}
<%
    HashMap  quotationMap = ( HashMap ) session.getAttribute( "quotationMap" );
    Quotation quotationFromMap = null;
    if ( quotationMap != null )
    {
        quotationFromMap = (Quotation)( quotationMap.get( quotationForm1.getCustomerId()+"" ));
        if( quotationFromMap != null )
        {
            pageContext.setAttribute( "billingAddressContactPersons", quotationFromMap.getContactPersonsForBillingAddress() );
            pageContext.setAttribute( "shippingAddressContactPersons", quotationFromMap.getContactPersonsForShippingAddress() );
            pageContext.setAttribute( "shippingAddresses", quotationFromMap.getShippingAddresses () );
            pageContext.setAttribute( "contactPersons", quotationFromMap.getContactPersons () );
            pageContext.setAttribute( "salesPersons", quotationFromMap.getSalesPersons() );
            pageContext.setAttribute( "salesReps", quotationFromMap.getSalesReps() );
            pageContext.setAttribute( "odmList", quotationFromMap.getOdmList() );
            pageContext.setAttribute( "endCustomerList", quotationFromMap.getEndCustomerList() );
        }
        ArrayList lineItemsList = (ArrayList) request.getAttribute ( "lineItems" );
       if ( lineItemsList == null )
       {
            lineItemsList = (ArrayList) session.getAttribute ( "lineItems" );
       }
       ArrayList customerPartNumbers = null;
       try
       {
           java.util.HashMap mapCustPartNos = quotationFromMap.getMfgPartsWithCustomerPartNos() ;
           for (int j = 0; j < lineItemsList.size(); j++) {
                LineItem lineItem = (LineItem) lineItemsList.get(j);
                customerPartNumbers = new ArrayList();
                if ( lineItem.getManufacturingPartNo() != null && lineItem.getManufacturingPartNo().trim().length() > 0)
                {
                    customerPartNumbers = (ArrayList)mapCustPartNos.get(lineItem.getManufacturingPartNo());
                }
                request.setAttribute( "customerPartNumbers"+lineItem.getLineItemNo(),  customerPartNumbers);
           }
       }
      catch(Exception ex)
      {
          System.out.println(ex);
          ex.printStackTrace();
      }

    }
    HashMap contactPersonsList = quotationFromMap.getCustomerContactPersonMap();
    if(contactPersonsList != null)
    {
        int listSize = contactPersonsList.size();
        java.util.Iterator contactPersonsIterator = contactPersonsList.keySet().iterator();
        ContactPerson contactPersons[] = new ContactPerson[listSize];
        %>
            var customerContactPerson = new Array(<%=listSize%>);
            var customerPhNo          = new Array(<%=listSize%>);
            var customerCellNo        = new Array(<%=listSize%>);
            var customerFax           = new Array(<%=listSize%>);
            var customerEmail         = new Array(<%=listSize%>);
            customerContactPerson[-3] = '';
            customerContactPerson[-2] = -1;
            customerContactPerson[-1] = '';
        <%
        for( int aa = 0; aa < listSize ; aa++)
        {
           Object key = (String)contactPersonsIterator.next();
           if( contactPersonsList.get(key)!= null )
            {
                if(contactPersonsList.containsKey(key))
                {
                    contactPersons[aa] = (ContactPerson)contactPersonsList.get(key);
                    %>
                        customerContactPerson[<%=aa%>] = '<%=contactPersons[aa].getContactPerson().replaceAll("'","\\\\" + "'")%>';
                        customerPhNo[<%=aa%>]          = '<%=contactPersons[aa].getPhoneNumber().replaceAll("'","\\\\" + "'")%>';
                        customerCellNo[<%=aa%>]        = '<%=contactPersons[aa].getCellNumber().replaceAll("'","\\\\" + "'")%>';
                        customerFax[<%=aa%>]           = '<%=contactPersons[aa].getFaxNumber().replaceAll("'","\\\\" + "'")%>';
                        customerEmail[<%=aa%>]         = '<%=contactPersons[aa].getEmail()%>';
                    <%
               }
           }
       } //for
   }
%>
<%
    HashMap billAddressList = quotationFromMap.getBillingAddressMap();
    if(billAddressList != null)
    {
        int billListSize = billAddressList.size();
        java.util.Iterator billContactPersonsIterator = billAddressList.keySet().iterator();
        String billAddresses[] = new String[billListSize];
        %>
            var billContactPerson = new Array(<%=billListSize%>);
            var billAddress       = new Array(<%=billListSize%>);
            billContactPerson[-3] = '';
            billContactPerson[-2] = -1;
            billContactPerson[-1] = '';
        <%
        for( int bb = 0; bb < billListSize ; bb++)
        {
           Object key = (String)billContactPersonsIterator.next();
           if( billAddressList.get(key)!= null )
            {
                if(billAddressList.containsKey(key))
                {
                    billAddresses[bb] = (String)billAddressList.get(key);
                    %>
                        billContactPerson[<%=bb%>] = '<%=key.toString().replaceAll("'","\\\\" + "'")%>';
                        billAddress[<%=bb%>]       = '<%=(billAddresses[bb].toString()).replace('\n','~').replaceAll("'","\\\\" + "'")%>';
                    <%
               }
           }
       } //for
   }
%>
<%
    HashMap shipAddressList = quotationFromMap.getShippingAddressMap();
    if(shipAddressList != null)
    {
        int shipListSize = shipAddressList.size();
        java.util.Iterator shipContactPersonsIterator = shipAddressList.keySet().iterator();
        String shipAddresses[] = new String[shipListSize];
        %>
            var shipContactPerson = new Array(<%=shipListSize%>);
            var shipAddress       = new Array(<%=shipListSize%>);
            shipContactPerson[-3] = '';
            shipContactPerson[-2] = -1;
            shipContactPerson[-1] = '';
        <%
        for( int bb = 0; bb < shipListSize ; bb++)
        {
           Object key = (String)shipContactPersonsIterator.next();
           if( shipAddressList.get(key)!= null )
            {
                if(shipAddressList.containsKey(key))
                {
                    shipAddresses[bb] = (String)shipAddressList.get(key);
                    %>
                        shipContactPerson[<%=bb%>] = '<%=key.toString().replaceAll("'","\\\\" + "'")%>';
                        shipAddress[<%=bb%>]       = '<%=(shipAddresses[bb].toString()).replace('\n','~').replaceAll("'","\\\\" + "'")%>';


                    <%
               }
           }
       } //for
   }
%>

<%
    ArrayList shipArr = quotationFromMap.getShippingMethods ();
    int size1 =0;
    if(shipArr !=  null)
    {
        size1 = shipArr.size();
    }
%>
    var shppingLables = new Array(<%=size1%>);
    var shppingValues = new Array(<%=size1%>);
<%
    if( shipArr != null)
    {
%>
        shppingLables[-2] = '';
        shppingLables[-1] = '';
<%
        for(int s = 0 ; s < shipArr.size() ; s++)
        {
%>
            shppingLables[<%=s%>] = '<%=((org.apache.struts.util.LabelValueBean)shipArr.get(s)).getLabel().replaceAll("'","\\\\" + "'")%>';
            shppingValues[<%=s%>] ='<%=((org.apache.struts.util.LabelValueBean)shipArr.get(s)).getValue().replaceAll("'","\\\\" + "'")%>';
<%
        }
%>
        shppingLables[<%=size1%>] = -2 ;
<%
   }
%>

    if( document.layers )
    {
        window.setResizable( false );
    }
    var count = <%= (String)session.getAttribute("maxLineItemNo") %>
    var errors  = "";
	var errors1 = "";
    var dateElement = "";
    function openCalendar(dateValue)
    {
        dateElement = dateValue;
        newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','calenderPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
        newWindow.moveTo(550,180);
        newWindow.focus();
    }
    function assignDate(passedValue)
    {
        dateElement.value=passedValue;
        window.focus();
    }
    function addTextArea()
    {
        var tab = document.getElementById("lineItemsTable");
        var index = document.getElementById ("rowIndex").rowIndex;

        var newRow = tab.insertRow ( index);
        var newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        var htmltext = '<input type="text" name="lineItemNo" value="'+count+'" size=6 class="txfield" disabled="true">';
        htmltext = htmltext + '<input type="hidden" name="lineItemNo" value="'+count+'">';
        htmltext = htmltext + '<input type="hidden" name="jsLineItemNo" value="'+count+'">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        htmltext = '<input type="text" name="poLineItemNo" value="'+count+'" size=6 class="txfield" disabled="true">';
        htmltext = htmltext + '<input type="hidden" name="poLineItemNo" value="'+count+'">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        htmltext = '<select name="manufacturingPartNo" class="txfield" onchange="getComments('+(count-1)+')"><option value="" >Select Part Number</option>';

        <%

            java.util.ArrayList optionlist = null;
            java.util.ArrayList mfgList = null;
            org.apache.struts.util.LabelValueBean option = null;
            CustomerPartNumber customerPartNo = new  CustomerPartNumber();
            StringBuffer strBuffer = null;
            StringBuffer strBuffer1 = null;
            int mfgListsize =0;

            try
            {
                    mfgList = quotationFromMap.getMfgParts();
                    if( mfgList == null)  mfgList =  new java.util.ArrayList();
                    mfgListsize = mfgList.size();
                    strBuffer1 = new StringBuffer();
                    for( int j = 0; j < mfgListsize; j++)
                    {
                        customerPartNo = (CustomerPartNumber)mfgList.get(j);
                        strBuffer1.append("htmltext = htmltext + '");
                        strBuffer1.append("<option value=\"").append(customerPartNo.getManufacturingPartNo()).append("\">");
                        strBuffer1.append(customerPartNo.getManufacturingPartNo()).append("</option>';\n");
                    }
                    out.println(strBuffer1);
            }
            catch(Exception ex) { }
        %>
        htmltext = htmltext + '</select>';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        newCell.noWrap = true;
        htmltext = '<select name="customerPartNo"  class="txfield" onchange="showHideNewCustPartNo(' + (count-1)+ ')"><option value="">Select Customer Part No</option><option value="-2">--Add New CustomerPart No--</option></select><input type="text" name="newCustomerPartNo" maxlength="50" size="20" value="" style="display:none;" class="txfield">';
        newCell.innerHTML = htmltext;
        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        newCell.style.noWrap = true;
        htmltext = '<textarea name="lineItemDescription" class="txfield" onkeydown="javascript:setTextAreaMaxLength(this,200)" onkeyup="javascript:setTextAreaMaxLength(this,200)"></textarea>';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        newCell.style.textAlign = "center";
        htmltext = '<input type=checkbox name="isTaxable'+count+'">';
        newCell.innerHTML = htmltext;
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        newCell.noWrap = true;
        htmltext = '<input type="text" name="requestDate" size=15 class="txfield">';
        htmltext = htmltext + '&nbsp;<a href="javascript:if(document.QuotationForm.requestDate.length!=null){openCalendar(document.QuotationForm.requestDate['+(count-1)+'])}else{openCalendar(document.QuotationForm.requestDate)}"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></img></a>';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        htmltext = '<select name="leadTime"  class="txfield">';
        htmltext = htmltext + '<option value="0">Select Lead Time</option>';
        htmltext = htmltext + '<option value="In Stock">In Stock</option>';
        htmltext = htmltext + '<option value="3-4 Weeks">3-4 Weeks</option>';
        htmltext = htmltext + '<option value="4-6 Weeks">4-6 Weeks</option>';
        htmltext = htmltext + '<option value="8-10 Weeks">8-10 Weeks</option>';
        htmltext = htmltext + '<option value="11-14 Weeks">11-14 Weeks</option>';
        htmltext = htmltext + '<option value="> 14 Weeks">> 14 Weeks</option>';
        htmltext = htmltext + '</select>';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        htmltext = '<input type="text" name="quantity" size=8 class="valuetxfield" value="0" onkeypress="javascript:allowInteger()"  maxlength="6">';
        htmltext = htmltext + '<input type="hidden" name="oldQty" value="0">';
        newCell.innerHTML = htmltext;
        <%
            if(ConfigManager.isShowQuoteMinOrderQty()) {
        %>
            newCell = newRow.insertCell();
            newCell.style.backgroundColor="#DEE1E2";
            htmltext = '<input type="text" name="minOrderQty" size=8 class="valuetxfield" value="0" onkeypress="javascript:allowInteger()"  maxlength="6">';
            newCell.innerHTML = htmltext;
        <%
            }
        %>
        <%
            if ( quotationForm1.isDistributor() )
            {
                if ( ConfigManager.isShowQuoteRequestedPrice() )
                {
        %>
                    newCell = newRow.insertCell();
                    newCell.style.backgroundColor="#DEE1E2";
                    htmltext = '<input type="text" name="reqPrice" size=12 class="valuetxfield" value="0.0" maxlength="9" onkeypress="<%=restrictCharsJSFnc2%>" onchange="reqPriceChanged('+(count-1)+')">';
                    newCell.innerHTML = htmltext;
        <%
                }
                if ( ConfigManager.isShowQuoteCustResalePrice() )
                {
        %>
                    newCell = newRow.insertCell();
                    newCell.style.backgroundColor="#DEE1E2";
                    htmltext = '<input type="text" name="custResalePrice" size=12 class="valuetxfield" value="0.0" maxlength="9" onkeypress="<%=restrictCharsJSFnc2%>" onchange="custResalePriceChanged('+(count-1)+')">';
                    newCell.innerHTML = htmltext;
        <%
                }
            }
        %>
        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        htmltext = '<input type="text" name="unitPriceAsDouble" size=12 class="valuetxfield" value="0.0" maxlength="9" onkeypress="<%=restrictCharsJSFnc%>" onkeyup="<%=restrictAmtJSFnc%>">';
        newCell.innerHTML = htmltext;
        <%
            if ( quotationForm1.isDistributor() )
            {
                if ( ConfigManager.isShowQuoteSuggResalePrice() )
                {
        %>
                    newCell = newRow.insertCell();
                    newCell.style.backgroundColor="#DEE1E2";
                    htmltext = '<input type="text" name="suggResalePrice" size=12 class="valuetxfield" value="0.0" maxlength="9" onkeypress="<%=restrictCharsJSFnc%>" onkeyup="<%=restrictAmtJSFnc%>">';
                    newCell.innerHTML = htmltext;
        <%
                }
            }
        %>
        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        htmltext = '<input type="text" name="amount" size=25 class="valuetxfield" value="$0.00" disabled="true">';
        newCell.innerHTML = htmltext;

        newCell = newRow.insertCell();
        newCell.style.backgroundColor="#DEE1E2";
        newCell.style.textAlign = "center";
        htmltext = '<input type=checkbox name="zeroPrice'+count+'" onClick="javascript:setZeroPrice('+( count-1 )+', '+count+')">';
        newCell.innerHTML = htmltext;

        count++;
    }
    function AddShippingTerms ()
	{
		var shippinglabel = document.getElementById("newShippingTerms");
		if(document.QuotationForm.shippingTerms.value == -2 )
		{
            document.QuotationForm.newShippingTerms.style.visibility = "visible";
			document.QuotationForm.newShippingTerms.value = '';
            shippinglabel.innerHTML = "New Pay Terms : ";
		}
		else
		{
            document.QuotationForm.newShippingTerms.style.visibility = "hidden";
			shippinglabel.innerHTML = "";
		}
	}
    function AddDeliveryTerms ()
	{
		var deliveryTermsLabel = document.getElementById("newDeliveryTerms");
		if(document.QuotationForm.deliveryTerms.value == -2 )
		{
			 document.QuotationForm.newDeliveryTerms.style.visibility = "visible";
			 document.QuotationForm.newDeliveryTerms.value = '';
			 deliveryTermsLabel.innerHTML = "New <bean:message key="label.sales.salesOrder.DeliveryTerms" /> : ";
             document.QuotationForm.newDeliveryTerms.focus();
		}
		else
		{
			 document.QuotationForm.newDeliveryTerms.style.visibility = "hidden";
			 deliveryTermsLabel.innerHTML = "";
		}
	}

    function AddNewShippingAddress(addElement)
    {
        //Restricting the user from entering more than one new shipping address
        var pa = document.getElementById("errors");
        pa.innerHTML = "";

        for( var i = 0; i < document.QuotationForm.shippingAddressId.length; i++ )
        {
            if( document.QuotationForm.shippingAddressId[i].value == -1 )
            {
                pa.innerHTML = "Can not add more than one new Shipping Address";
                return;
            }
        }
        shipElement = addElement.name;
        if(document.QuotationForm.endUser.value == '')
        {
            if( document.QuotationForm.isEndCustomerShipAddress.checked && Number( document.QuotationForm.odmId.value ) > 0 )
            {
                customerId = document.QuotationForm.odmId.value;
            }
            else
            {
                customerId = document.QuotationForm.customerId.value;
            }
            newWindow = window.open('addAddress.do?action=AddShippingAddress&customerId='+customerId,'shippingAddressPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=400,height=400,left=550,top=180,resizable=no');
            newWindow.focus();
        }
        else
        {
            newWindow = window.open('addEndUserAddress.do?action=AddEndUserShippingAddress&endUserId='+document.QuotationForm.endUserId.value,'shippingAddressPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=400,height=400,left=550,top=180,resizable=no');
  	        newWindow.focus();
        }
    }

    function showHideNewEndUserField()
    {
    var form = document.QuotationForm;
    var endUserCtrl = form.endCustomerId;
    var newEndUserNameCtrl = form.newEndUserName;
    var endUserLabelSpan = document.getElementById ( "endUserLabelSpan" );
    var endUserTxfieldSpan = document.getElementById ( "endUserTxfieldSpan" );
    if ( endUserCtrl.value == "-2" )
    {
        endUserLabelSpan.style.display = 'block'
        endUserTxfieldSpan.style.display = 'block'
    }
    else
    {
        newEndUserNameCtrl.value = "";
        endUserLabelSpan.style.display = 'none'
        endUserTxfieldSpan.style.display = 'none'
    }
}
    function assignShippingAddress(elementName)
    {
        enableCustPartNos();
        document.QuotationForm.shippingAddress.disabled = false;
        document.QuotationForm.billingAddress.disabled = false;
        document.QuotationForm.action.value = "loadShippingAddress";
        document.QuotationForm.submit();
    }

    function assignShippingInstructions(elementName)
    {
        var shippingInstructions = document.getElementById("shippingInstructions");
        if ( elementName.value == "-1" )
        {
            shippingInstructions.innerHTML = "<bean:message key="label.sales.shippingInstructions" />"
            document.QuotationForm.shippingInstructions.value = "";
            document.QuotationForm.shippingInstructions.readOnly = true;
        }
        else if ( elementName.value == "-2")
        {
            shippingInstructions.innerHTML = "New <bean:message key="label.sales.shippingInstructions" />"
            document.QuotationForm.shippingInstructions.value = "";
            document.QuotationForm.shippingInstructions.readOnly = false;
            document.QuotationForm.shippingInstructions.focus();
        }
        else if ( Number( elementName.value ) > 0 )
        {
            enableCustPartNos();//function
            document.QuotationForm.shippingAddress.disabled = false;
            document.QuotationForm.billingAddress.disabled = false;
            document.QuotationForm.action.value = "loadShippingInstructions";
            document.QuotationForm.submit();
        }
    }
    function setReadOnlyForFreightInsructions ( elementName )
    {
        if ( elementName.value == "-1" )
        {
            freightInstructionLabel.innerText = "Freight Instructions:"
            document.QuotationForm.freightInstructions.readOnly = true;
            document.QuotationForm.freightInstructions.value = "";
        }
        if ( elementName.value == "-2")
        {
            freightInstructionLabel.innerText = "New Freight Instructions:"
            document.QuotationForm.freightInstructions.readOnly = false;
            //document.QuotationForm.freightInstructions.value = "";
        }
        else if ( Number( elementName.value ) > 0 )
        {
            freightInstructionLabel.innerText = "Freight Instructions:"
            document.QuotationForm.freightInstructions.readOnly = true;
        }
    }
    function assignFreightInstructions(elementName)
    {
        if ( elementName.value == "-1" )
        {
            freightInstructionLabel.innerText = "Freight Instructions:"
            document.QuotationForm.freightInstructions.readOnly = true;
            document.QuotationForm.freightInstructions.value = "";
        }
        else if ( elementName.value == "-2" )
        {
            freightInstructionLabel.innerText = "New Freight Instructions:"
            document.QuotationForm.freightInstructions.readOnly = false;
            document.QuotationForm.freightInstructions.value = "";
            document.QuotationForm.freightInstructions.focus();
        }
        else if ( Number( elementName.value ) > 0 )
        {
            enableCustPartNos();//function
            document.QuotationForm.shippingAddress.disabled = false;
            document.QuotationForm.billingAddress.disabled = false;
            document.QuotationForm.action.value = "loadFreightInstructions";
            document.QuotationForm.submit();
        }
    }

    function getCustomerShippingAddress()
    {
        var isEndCustomerShipAddress      = document.QuotationForm["isEndCustomerShipAddress"];
        isEndCustomerShipAddress.checked = false;   //TO LOAD CUSTOMER SHIPPING ADDRESSES..
        enableCustPartNos();//function
        document.QuotationForm.shippingAddress.disabled = false;
        document.QuotationForm.billingAddress.disabled = false;
        document.QuotationForm.action.value = "loadEndCustomerDefualtShippingAddress";
        document.QuotationForm.submit();
    }

    function getEndCustomerShippingAddress(elementName)
    {
        var endCustomerId      = document.QuotationForm["odmId"];
        var pa                 = document.getElementById("errors1");
        if ( elementName.checked )
        {
            if ( endCustomerId.value <= 0 )
            {
                pa.innerHTML = "<li>Please select <bean:message key="label.sales.shipToCustomer"/></li>"
                elementName.checked = false;
                return;
            }
        }
        enableCustPartNos();//function
        document.QuotationForm.shippingAddress.disabled = false;
        document.QuotationForm.billingAddress.disabled = false;
        document.QuotationForm.action.value = "loadEndCustomerDefualtShippingAddress";
        document.QuotationForm.submit();
    }

    //Function for adding a new option to the shippingAddressId select list
    function addShippingAddressIdOption(optionContent,optionValue)
    {
        document.QuotationForm.shippingAddressId.add(new Option(optionContent,optionValue));
    }

    function addShippingAddressContactPerson(shipAddressWithoutContactPerson,strShippingAddress,contactPerson)
    {
        document.QuotationForm.shippingAddress.value=strShippingAddress;
        document.QuotationForm.shippingAddressId.value=-1;
        document.QuotationForm.shippingContactPerson.length=0;
        document.QuotationForm.shippingContactPerson.length=2;
        document.QuotationForm.shippingContactPerson.options[0].text="--- Select ---";
        document.QuotationForm.shippingContactPerson.options[0].value="";
        document.QuotationForm.shippingContactPerson.options[1].text=contactPerson;
        document.QuotationForm.shippingContactPerson.options[1].value=contactPerson;
        document.QuotationForm.shippingContactPerson.value=contactPerson;

        shipContactPerson.length = 2;
        shipAddress.length = 2;

        shipContactPerson[0] = '';
        shipAddress[0]       = shipAddressWithoutContactPerson;

        shipContactPerson[1] = contactPerson;
        shipAddress[1]       = strShippingAddress;
    }

    function addShippingMethod(methodname)
    {
        var pa11=document.getElementById("shippingAccount");
        var pa1=document.getElementById("newshippingMethod");
        var pa3=document.getElementById("newshippingAccount");

		document.QuotationForm.shipAccount1.value = document.QuotationForm.shippingMethod.value;

        if (methodname.value == -2)
        {
             <%--document.QuotationForm.newshippingMethod.style.visibility = "visible";
             pa1.innerHTML = "<bean:message key="label.sales.salesOrder.NewShippingMethod"/>:&nbsp;<font color=red>*</font>";

             document.QuotationForm.newshippingAccount.style.visibility = "visible";
             pa3.innerHTML = "<bean:message key="label.sales.salesOrder.NewShippingAccount"/>:&nbsp;<font color=red>*</font>";--%>
            var form = document.QuotationForm;
            document.QuotationForm.shipAccount1.value = -1;
            form.shippingMethod.value = -1;
            form.shippingMethodName.value = " ";
            form.shippingAccount.value = " ";
            var LeftPos=(screen.width)?(screen.width-500)/2:100;
            var TopPos=(screen.height)?(screen.height-450)/2:100;
            newWindow = window.open ('<%=chipTracContext%>/shippingMethodPopupAction.do?action=load&fromScreen=quote&customerId='+form.customerId.value+"&endCustomerId="+form.odmId.value,"editShippingMethod",'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=540,height=500,resizable=yes,Left= '+LeftPos+',top='+TopPos);
            newWindow.focus();
        }
        else
        {
            document.QuotationForm.newshippingMethod.value='';
            document.QuotationForm.newshippingAccount.value='';
            if (methodname.value == -1)
            {
                document.QuotationForm.shippingMethodName.value = " ";
                document.QuotationForm.shippingAccount.value = " ";
            }
            document.QuotationForm.newshippingMethod.style.visibility = "hidden";
            pa1.innerHTML = "";
            document.QuotationForm.newshippingAccount.style.visibility = "hidden";
            pa3.innerHTML = "";

            assignShippingAccount(methodname);
        }
    }


    function taxFocus()
    {
         document.QuotationForm.newSalesTax.focus();
    }

    var flag = true;
    function addNewSalesTaxType(statename)
    {
        if(statename.value == -1)
        {
            if(flag == true)
            {
                var htmltext1 = '<font class="NArialL">New State :</font>&nbsp;'
                var htmltext2 = '<input type="text" name="newSalesState" size="18" maxlength="25" class="txfield" onblur ="javascript:taxFocus();" >'
                var htmltext3 = '<font class="NArialL">New Tax :</font>&nbsp;'
                var htmltext4 = '<input type="text" name="newSalesTax" size="18" maxlength="6" class="txfield" onkeypress="javascript:restrictCharacters(this,3,<%=ConfigManager.getnoOfDecmalsInAmount()%>)" onkeyup="javascript:restrictAmt(this,3,<%=ConfigManager.getnoOfDecmalsInAmount()%>)">'

                var p1=document.getElementById("font-1");
                var p2=document.getElementById("font-2");

                p1.insertAdjacentHTML('BeforeEnd',htmltext1);
                p2.insertAdjacentHTML('BeforeEnd',htmltext2);

                var p3=document.getElementById("font-3");
                var p4=document.getElementById("font-4");

                p3.insertAdjacentHTML('BeforeEnd',htmltext3);
                p4.insertAdjacentHTML('BeforeEnd',htmltext4);

                flag = false;
       		}
        }
    }

    function assignShippingAccount(elementName)
    {
        var len = elementName.length;

        for(var i=0; i< len; i++)
        {
             if(elementName.options[i].selected)
             {
                document.QuotationForm.shippingMethodName.value = elementName.options[i].innerText;
             }
        }

		if(document.QuotationForm.shippingMethod.value != -1)
		{
		   document.QuotationForm.shippingAccount.value = elementName.value;
		}
		else
		if(document.QuotationForm.shippingMethod.value == -1)
		{
		   document.QuotationForm.shippingAccount.value = '';
		   document.QuotationForm.shippingMethodName.value = '';
		}
    }

    function dateValidation()
    {
        var dateValue = "";
	    var temp = document.QuotationForm["requestDate"];
        if ( temp.length == null )
        {
            if( chkDate(temp.value,"Requested Dock Date","Y") == false)
            {
                errors = errMsg;
                temp.select();
                temp.focus();
            }
            else
            {
                return false;
            }
        }
	    else
        {
		    var partNo = document.QuotationForm["manufacturingPartNo"];
		    var i;
            for( i=0; i < temp.length; i++)
            {
                if( partNo[i].value != '')
                {
                    if( chkDate(temp[i].value,"Requested Dock Date ","Y") == false)
                    {
                        errors = errMsg;
                        temp[i].select();
                        temp[i].focus();
                        break;
                    }
                }
            }
        }

        if(errors != '')
            return false;
        else
            return true;
    }

    function validateRequestDate(temp)
    {
        errors = "";
        validateDate(temp.value);
        var pa=document.getElementById("errors");
        pa.innerHTML = errors;

    	return;
    }

    function selectContactPerson (element,idValue, indexValue)
    {
        if( element =='CustomerContactPerson' )
        {
            for( ss = 0; ss < customerContactPerson.length; ss++ )
            {
                if( document.QuotationForm.contactPerson.value == customerContactPerson[ss] )
                {
                     document.QuotationForm.contactPerson.value = customerContactPerson[ss];
                     document.QuotationForm.phoneNumber.value = customerPhNo[ss];
                     document.QuotationForm.cellNumber.value = customerCellNo[ss];
                     document.QuotationForm.faxNumber.value = customerFax[ss];
                     document.QuotationForm.email.value = customerEmail[ss];

                     document.QuotationForm.phoneNumber.disabled = false;
                     document.QuotationForm.cellNumber.disabled = false;
                     document.QuotationForm.faxNumber.disabled = false;
                     document.QuotationForm.email.disabled = false;
                     if( document.QuotationForm.customerName.value == customerContactPerson[ss] )
                     {
                        document.QuotationForm.cellNumber.disabled = true;
                     }
                }
                else  if( document.QuotationForm.contactPerson.value == '' )
                {
                     document.QuotationForm.contactPerson.value = '';
                     document.QuotationForm.phoneNumber.value = '';
                     document.QuotationForm.cellNumber.value = '';
                     document.QuotationForm.faxNumber.value = '';
                     document.QuotationForm.email.value = '';

                     document.QuotationForm.phoneNumber.disabled = true;
                     document.QuotationForm.cellNumber.disabled = true;
                     document.QuotationForm.faxNumber.disabled = true;
                     document.QuotationForm.email.disabled = true;
                }
            }
        }
        var ww = document.QuotationForm.billingContactPerson.selectedIndex;
    	if( element =='BillingContactPerson' )
    	{
    		 for( pp = 0; pp < billContactPerson.length; pp++ )
    		 {
    			if( document.QuotationForm.billingContactPerson.value == billContactPerson[pp] )
    			{
    				 document.QuotationForm.billingContactPerson.value = billContactPerson[pp];
    				 document.QuotationForm.billingAddress.value = billAddress[pp].replace(/~/g,'\n') ;
    			}
    		 }
    	}
    	if( element =='ShippingContactPerson' )
    	{

    		 for( ff = 0; ff < shipContactPerson.length; ff++ )
    		 {
    			if( document.QuotationForm.shippingContactPerson.value == shipContactPerson[ff] )
    			{
    				 document.QuotationForm.shippingContactPerson.value = shipContactPerson[ff];
    				 document.QuotationForm.shippingAddress.value = shipAddress[ff].replace(/~/g,'\n');
    			}
    		 }
    	}

    }

    function submitPage(action)
    {
        errors  = "";
		errors1 = "";
		document.getElementById("errors1").innerHTML = '';
		if(!dateValidation())
        {
            errors = errors;
        }

        var qty = document.QuotationForm["quantity"];
        var leadTime=document.QuotationForm["leadTime"];
        var price = document.QuotationForm["unitPriceAsDouble"];
        var partNo = document.QuotationForm["manufacturingPartNo"];
        var quotationNo = document.QuotationForm["quotationNo"];
        var contactPerson = document.QuotationForm["contactPerson"];
        var salesPerson = document.QuotationForm["salesPerson"];
        var endUser = document.QuotationForm["endUser"];
        var regionalRep = document.QuotationForm["regionalRep"];
        var shippingAccount = document.QuotationForm["shippingAccount"];
        var shippingTerms = document.QuotationForm["shippingTerms"];
        var deliveryTerms = document.QuotationForm["deliveryTerms"];
        var phoneNumber = document.QuotationForm["phoneNumber"];
        var email = document.QuotationForm["email"];
        var faxNumber = document.QuotationForm["faxNumber"];
        var cellNumber = document.QuotationForm["cellNumber"];
        var comments = document.QuotationForm["comments"];
        var shippingInstructions = document.QuotationForm["shippingInstructions"];
        var freightInstructions = document.QuotationForm["freightInstructions"];
        var frieght = document.QuotationForm["frieghtAsDouble"];
        var misc = document.QuotationForm["miscAsDouble"];
        var date = document.QuotationForm["requestDate"];
        document.QuotationForm.frieghtAsDouble.value = stripCharsInBag(document.QuotationForm["frieghtAsDouble"].value,"$, ");
        document.QuotationForm.miscAsDouble.value = stripCharsInBag(document.QuotationForm["miscAsDouble"].value,"$, ");
        var quoteType = document.QuotationForm["quoteType"];
                <%
            if ( ConfigManager.isQuoteTypeMandatory() )
            {
        %>
                if ( quoteType.value == "-1" || quoteType.value == "-2" )
                {
                    errors1 = errors1 +'<br>' + "<li>  Please select Quote Type";
                }
        <%
            }
        %>
        if(document.QuotationForm["quantity"].length == null)
        {
			if(partNo.value != '')
			{
                if(partNo.value == '---- BOARD -----' || partNo.value == '---- KIT -----' || partNo.value == '---- CHIPS -----')
                {
                    errors = errors +'<br>' + "<li>  Please select the Part Number ";
                }
                if(qty.value != '')
                {
                    if(!isInteger(qty.value))
                    {
                        errors = errors +'<br>' + "<li>  Please enter a valid quantity ";
                        qty.select();
                    }
                    else if(qty.value == 0)
                    {
                        errors = errors +'<br>' + "<li>  Please enter a valid quantity ";
                        qty.select();
                    }
                    else if((qty.value).length > 6)
                    {
                        errors = errors +'<br>' + "<li>  Please enter a valid quantity (should not allow more than 6 digits)";
                        qty.select();
                    }
                }
                else
                {
                    errors = errors +'<br>' + "<li>  Please enter the quantity";
                }
            }
            else
            {
                errors = errors +'<br>' + "<li>  Please select the Part Number ";
            }
         }
         else
         {
            for(var i=0; i< qty.length; i++)
            {
                if(partNo[i].value != '')
                {
					if(partNo[i].value == '---- BOARD -----' || partNo[i].value == '---- KIT -----' || partNo[i].value == '---- CHIPS -----' )
					{
						errors = errors +'<br>' + "<li>  Please select the Part Number for Lineitem"+(i+1);
						break;
					}

                    if (qty[i].value != '')
                    {
			            if(!isInteger(qty[i].value))
                        {
				            errors = errors +'<br>' + "<li>  Please enter a valid quantity ";
				            qty[i].select();
							break;
			            }
                        else if(qty[i].value == 0)
                        {
				            errors = errors + '<br>' +"<li>  Please enter a valid quantity ";
				            qty[i].select();
							break;
			            }
                        else  if((qty[i].value).length > 6)
                        {
				            errors = errors + '<br>' +"<li>  Please enter a valid quantity (should not allow more than 6 digits)";
				            qty[i].select();
							break;
         		        }
                    }
                    else
                    {
			            errors = errors +'<br>' + "<li>  Please enter the quantity";
                        qty[i].select();
						break;
                    }
		        }
                else if( (trim(qty[i].value).length != 1 && trim(qty[i].value) != 0 ) || (trim(date[i].value).length != 0) )
                {
                    if(partNo[i].value == '')
                    {
                        errors = errors +'<br>' + "<li>  Please select the Part Number for Lineitem"+(i+1);
                        break;
                    }
                }
            }
         }
        if(document.QuotationForm["unitPriceAsDouble"].length == null)
        {
            if(price.value != '')
            {
                var j = 0;
                for(var k = 0; k < (price.value).length;k++)
	            {
		            var c = (price.value).charAt(k);
		            if( c == '.' )
		            {
			            j++;
                        if(j > 1 )
                        {
                            errors = errors +'<br>' + "<li>  Please enter a valid price";
	 				        price.select();
							break;
                        }
                    }
               }

			   if(check_char_position4(price.value) || (is_Sp_Characters_frieght(price.value) == false)  )
			   {
					 errors = errors +'<br>' + "<li>  Please enter a valid price";
					 price.select();
			   }

	        }
            else
            {
	            errors = errors +'<br>' + "<li>  Please enter the price";
	        }
	      }
          else
          {

	        for(var i=0; i< price.length; i++)
	        {
	            if(partNo[i].value != '')
                {
	                if (price[i].value != '')
                    {
                        var j = 0;
                        for(var k = 0; k < (price[i].value).length;k++)
	                    {
		                    var c = (price[i].value).charAt(k);
		                    if( c == '.' )
		                    {
			                    j++;
                                if(j > 1 )
                                {
                                    errors = errors +'<br>' + "<li>  Please enter a valid price";
	 				                price[i].select();
							        break;
                                }
		                    }
	                    }

						if(check_char_position4(price[i].value) || (is_Sp_Characters_frieght(price[i].value) == false) )
                        {
	 				        errors = errors +'<br>' + "<li>  Please enter a valid price";
	 				        price[i].select();
							break;
	 			        }


	                }
                    else
                    {
	 			        errors = errors +'<br>' + "<li>  Please enter the price";
	                    price[i].select();
						break;
	                }
	 		    }

	            if(partNo[0].value =='')
                {
                    errors = "<li>  Please select the Part Number for Lineitem1";
	            }
	        }
	      }
          // End of Price validations
        /*if( document.QuotationForm["quantity"].length == null )
        {
            if ( leadTime.value == 0 )
            {
                errors = "<li>  Please select Lead Time";
            }
        }
        else
        {
            for(var i=0; i< leadTime.length; i++)
	        {
                if(partNo[i].value != '')
                {
                    if ( leadTime[i].value == 0 )
                    {
                        errors = "<li>  Please select Lead Time";
                    }
                }
            }
        }*/

       if( !(is_Sp_Characters_frieght(frieght.value)) || (check_char_position4(frieght.value)) )
	  {

	      errors = errors + '<br>' + "<li>  Freight should be a number ";
	  }

       if( !(is_Sp_Characters_frieght(misc.value)) || (check_char_position4(misc.value)) )
	  {

	      errors = errors + '<br>' + "<li>  Miscellaneous field should be a number ";
	  }


    // Sales Tax State Validations
	if( document.QuotationForm.salesTaxType.value == -1)
	{
	     var newState = document.QuotationForm.newSalesState.value;
	     var newTax = document.QuotationForm.newSalesTax.value;

          if( newState.length == 0 || newState == '')
          {
                errors = errors + '<br>' + "<li>  Please enter New State ";
          }
          if( newTax.length == 0 || newTax == '')
          {
                errors = errors + '<br>' + "<li>  Please enter New Tax ";
          }
         if( (newState.length == 0 || newState == '') &&  (newTax.length == 0 || newTax == ''))
          {
                 errors = ''
                 errors = errors + '<br>' + "<li> Please enter values for New State and New Tax";
          }
          if(  newState.length != 0 && newState != '')
          {
              if( !(is_Sp_Characters_State(newState)) || (check_char_position5(newState)) )
              {
                  errors = errors + '<br>' + "<li>  Please enter a valid state ";
              }
         }
        if( newTax.length != 0 && newTax != '')
        {
			var hh =0;
			if( !(is_Sp_Characters_frieght(newTax)) || (check_char_position4(newTax)) )
			{
			   errors = errors + '<br>' + "<li> New sales tax should be a number";
			}
			else if(newTax == 0 ||  newTax == '')
			{
				errors = '';
				errors = errors +'<br>' + "<li>  New Tax cannot be less than or equal to zero ";
			}
			for(var d = 0; d < newTax.length;d++)
			{
				var c = (newTax).charAt(d);
				if( c == '.' )
				{
					hh++;
					if(hh > 1 )
					{
						errors = errors +'<br>' + "<li> New Tax should be valid number and first digit can not be space or zero ";
						break;
					}
				}
			} //for

        }

	}



        var statename1 = document.QuotationForm["salesTaxType"];
    	var status = false;

       for( var txble=1; txble < count; txble++ )
       {
	        var txval = "isTaxable"+txble;
            if(document.QuotationForm[txval] != null)
            {
	            if( document.QuotationForm[txval].checked == true )
                {
                    <%-- start: Added by Murali krishna, status is set to true only if the part no is selected for the line item whose 'isTaxable' is checked --%>
                    if(document.QuotationForm["quantity"].length == null)
                    {
                        if(partNo.value != '')
                        {
                            if( !(partNo.value == '---- BOARD -----' || partNo.value == '---- KIT -----' || partNo.value == '---- CHIPS -----') )
                            {
                                status = true;
                            }
                        }
                    }
                    else
                    {
                        if(partNo[txble-1].value != '')
                        {
                            if( !(partNo[txble-1].value == '---- BOARD -----' || partNo[txble-1].value == '---- KIT -----' || partNo[txble-1].value == '---- CHIPS -----') )
                            {
                                status = true;
                            }
                        }
                    }
                    <%-- end: Murali Krishna --%>

	                if( (statename1.value == 0) && (status == true) )
	                {
                        errors = errors+ '<br>' +"<li>  Please either select Tax from Sales Tax State or uncheck Taxable field";
                        break;
	                }
                }
            }
        }
        if( (statename1.value != 0) && (status == false))
        {
            errors = errors+ '<br>' +"<li>  Please either check atleast one Taxable field or Select NonTaxable option";
        }

				var pa=document.getElementById("errors");
				pa.innerHTML = errors;


				if(  (!(is_Sp_Characters(quotationNo.value))) || (check_char_position(quotationNo.value))  )
				{
					errors = errors + '<br>' + "<li>  QuotationNo should be a numerical and not start with  special characters";
				}

				if( (text_area(comments.value)) == true)
				{
					errors = errors + '<br>' + "<li>  Comments should not more than 300 Characters ...";
				}

                if( salesPerson.value < 0 )
                {
                    document.QuotationForm["salesPerson"].value = "";
                }

				if( (text_area(shippingInstructions.value)) == true)
				{
					errors = errors + '<br>' + "<li>  ShippingInstructions should not exceed 300 characters";
				}
                if( (text_area(freightInstructions.value)) == true)
				{
					errors = errors + '<br>' + "<li>  FreightInstructions should not exceed 300 characters";
				}



                var shipmethod = document.QuotationForm.shippingMethod.value;
                var shipaccount = document.QuotationForm.shippingAccount.value;
                if(document.QuotationForm.shippingMethod.value == -2)
                {
					var newshipmethod = document.QuotationForm.newshippingMethod.value;
					var newshipaccount = document.QuotationForm.newshippingAccount.value;
                    if( trim(newshipmethod) =='')
                    {
                        errors1 = errors1+ '<br>' +"<li>  Enter <bean:message key="label.sales.salesOrder.NewShippingMethod" />";
                        document.QuotationForm.newshippingMethod.focus();
                    }
                    if(trim(newshipaccount) == '')
                    {
                        errors1 = errors1+ '<br>' +"<li>  Enter <bean:message key="label.sales.salesOrder.NewShippingAccount" />";
                        document.QuotationForm.newshippingAccount.focus();
                    }
                    if(newshipmethod.indexOf('\'')>=0 || newshipmethod.indexOf('"')>=0 || newshipmethod.indexOf('#')>=0)
                    {
                        errors1 = errors1+'<br>'+'<li> Enter Valid <bean:message key="label.sales.salesOrder.NewShippingMethod" /> ( \' " # are not allowed ) ';
                        document.QuotationForm.newshippingMethod.select();
                        document.QuotationForm.newshippingMethod.focus();
                    }
                    if(newshipaccount.indexOf('\'')>=0 || newshipaccount.indexOf('"')>=0 || newshipaccount.indexOf('#')>=0)
                    {
                        errors1 = errors1+'<br>'+'<li> Enter Valid <bean:message key="label.sales.salesOrder.NewShippingAccount" /> ( \' " # are not allowed ) ';
                        document.QuotationForm.newshippingAccount.select();
                        document.QuotationForm.newshippingAccount.focus();
                    }
                    var tempShippingMethod =  newshipmethod.trim()+'   #   '+newshipaccount.trim();
                    for(var i = 0; i < shppingLables.length - 1; i++)
                    {
                        if(  shppingLables[i].toUpperCase() == tempShippingMethod.toUpperCase() )
                        {
                             errors1 = errors1 + '<li>' + newshipmethod + ' <bean:message key="label.sales.salesOrder.ShippingMethod" /> already Exists, Please enter another <bean:message key="label.sales.salesOrder.ShippingMethod" />';
                             document.QuotationForm.newshippingMethod.select();
                             document.QuotationForm.newshippingMethod.focus();
                        }
                    }
                }

            var shipTerms = document.QuotationForm.shippingTerms.value;
            var newshipTerms = document.QuotationForm.newShippingTerms.value;
            var deliveryTerms = document.QuotationForm.deliveryTerms.value;
            var newDeliveryTerms = document.QuotationForm.newDeliveryTerms.value;
            if( shipTerms == -2 )
            {
                if( newshipTerms == '' || newshipTerms.trim().length == 0 )
                {
                    errors1 = errors1+'<br>'+'<li> Enter New Pay Terms ';
                }
                else if( newshipTerms.indexOf('\'') >=0 || newshipTerms.indexOf('"') >= 0 )
                {
                    errors1 = errors1+'<br>'+'<li> Enter Valid Pay Terms ';
                    document.QuotationForm.newShippingTerms.select();
                    document.QuotationForm.newShippingTerms.focus();
                }
            }
            if( deliveryTerms == -2 )
            {
                if ( newDeliveryTerms == '' || newDeliveryTerms.trim().length == 0 )
                {
                    errors1 = errors1+'<br>'+'<li> Enter New <bean:message key="label.sales.salesOrder.DeliveryTerms" />'
                }
                else if( newDeliveryTerms.indexOf('\'') >= 0 || newDeliveryTerms.indexOf('"') >= 0)
                {
                    errors1 = errors1+'<br>'+'<li> Enter Valid <bean:message key="label.sales.salesOrder.DeliveryTerms" />';
                    document.QuotationForm.newDeliveryTerms.select();
                    document.QuotationForm.newDeliveryTerms.focus();
                }
            }

			var quotationNo = document.QuotationForm.quotationNo.value ;
			if( quotationNo == '')
			{
				document.QuotationForm.quotationNo.focus();
				errors1 = errors1 + '<br>' + "<li>  Please enter Quote No";
				location="#e1";
			}
			else
			 if( quotationNo != '')
			 {
                if( chkSalesOrderNoBegin(quotationNo) )
				 {
					document.QuotationForm.quotationNo.focus();
					errors1 = errors1 + '<br>' + "<li>  Quote No should not start with special characters ";
					location="#e1";
                 }
				 else
                 if( ! chkSalesOrderNo(quotationNo) )
                 {
					 document.QuotationForm.quotationNo.focus();
					 errors1 = errors1 + '<br>' + "<li>  Please enter Valid Quote No ";
					 location="#e1";
                 }
             }
             if( document.QuotationForm.poDate.value != '' && !validateBookingDate( document.QuotationForm.poDate.value ) )
             {
                 errors1 = errors1 +'<br>'+"<li> PO Date should be in 'mm/dd/yyyy' format ";
				 location="#e1";
             }
            <%
                if ( ConfigManager.isEndUserMandatory() )
                {
            %>
                    if ( document.QuotationForm.endCustomerId.value == '-1' || document.QuotationForm.endCustomerId.value == '' )
                    {
                        errors1 = errors1+ '<li> Please select <bean:message key="label.sales.endUser"/>';
                        document.QuotationForm.endCustomerId.focus();
                    }
                    else if ( document.QuotationForm.endCustomerId.value == '-2' && document.QuotationForm.newEndUserName.value.trim() == '' )
                    {
                        errors1 = errors1+ '<li> Please enter new <bean:message key="label.sales.endUser"/>';
                        document.QuotationForm.newEndUserName.focus();
                    }
            <%
                }
            %>
            <%
                if ( ConfigManager.isEndCustomerMandatory() )
                {
            %>
                    if ( document.QuotationForm.odmId.value == '-1' || document.QuotationForm.odmId.value == '' )
                    {
                        errors1 = errors1+ '<li> Please select <bean:message key="label.sales.endCustomer"/>';
                        document.QuotationForm.odmId.focus();
                    }
                    else if ( document.QuotationForm.odmId.value == '-2' && document.QuotationForm.newEndCustomerName.value.trim() == '' )
                    {
                        errors1 = errors1+ '<li> Please enter new <bean:message key="label.sales.endCustomer"/>';
                        document.QuotationForm.newEndCustomerName.focus();
                    }
            <%
                }
            %>

         if( email.value != '' )
           {
           if(!isValidEMailId (email))
            {
            errors1 = errors1 + '<br>'+'<li> Please enter a valid email address';
            email.select();
            email.focus();
            location="#e1";
           }

         }
            if( document.QuotationForm["shippingAddress"].value == '' )
            {
                errors1=errors1+ '<br>'+'<li> Please enter shipping Address';
            }

           var expiryDate = document.QuotationForm.expiryDate;
           var quotationDate = document.QuotationForm.quotationDate[0];
           if( chkDate(expiryDate.value,"Quotation Expiry Date","Y") == false)
		   {
				errors = errMsg;
				expiryDate.select();
				expiryDate.focus();
		   }
           if( chkDate(expiryDate.value,"Quotation Expiry Date","Y") && expiryDate.value != '' )
           {
               if( ValidateLeadDate1( quotationDate.value, expiryDate.value, "", "Y" ) == false ) {
                    errors = errors +'<br>' + "<li> Expiry Date should be greater than Quote Date";
                    expiryDate.select();
                    expiryDate.focus();
               }
           }

        if(phoneNumber.value.indexOf('"') >= 0)
        {
            errors1 = errors1 + '<br>' + "<li>Enter a valid Phone Number" ;
            phoneNumber.select();
            phoneNumber.focus();
        }
        if(faxNumber.value.indexOf('"') >= 0)
        {
            errors1 = errors1 + '<br>' + "<li>Enter a valid Fax Number" ;
            faxNumber.select();
            faxNumber.focus();
        }
        if(cellNumber.value.indexOf('"') >= 0)
        {
            errors1 = errors1 + '<br>' + "<li>Enter a valid Cell Number" ;
            cellNumber.select();
            cellNumber.focus();
        }

		if(errors1 != '')
        {
            var pa=document.getElementById("errors1");
            pa.innerHTML = errors1;
			return;
        }

		if(errors != '')
        {
            var pa=document.getElementById("errors");
            pa.innerHTML = errors;
	        return;
        }
        document.QuotationForm.shippingAddress.disabled = false;
        document.QuotationForm.billingAddress.disabled = false;
        document.QuotationForm.phoneNumber.disabled = false;
        document.QuotationForm.faxNumber.disabled = false;
        document.QuotationForm.email.disabled = false;


        if(document.QuotationForm["quantity"].length==null)
        {
             var element = eval("document.QuotationForm.zeroPrice" + (document.QuotationForm.jsLineItemNo.value) );
            if(element.checked == true &&  price.value > 0 )
            {
                pa.innerHTML = "<li>Price field can not take a value greater than zero when \" zero price \" option is selected";
                price.focus();
                return;
            }
        }
        else
        {
            var zeroPriceCount=document.QuotationForm["quantity"].length;

            for(i=0;i< zeroPriceCount;i++)
            {
                if(qty[i].value > 0 )
                {
                    var element = eval( "document.QuotationForm.zeroPrice" + (document.QuotationForm.jsLineItemNo[i].value) );
                    if(element != null)
                    {
                        if(element.checked == true &&  price[i].value > 0 )
                        {
                            pa.innerHTML = "<li>Price field can not take a value greater than zero when \" zero price \" option is selected";
                            price[i].focus();
                            return;
                        }
                    }
                }
            }
        }
        var description = document.QuotationForm["lineItemDescription"];
        var length = document.QuotationForm["lineItemDescription"].length
        if(length == null)
        {
            if(description.value.length > 200)
            {
                   pa.innerHTML = "<li>Description Should be Maximum of 200 Characters. ";
                   description.focus();
                   description.select();
                   return;
            }
        }
        else
        {
            for(var i=0;i< length;i++)
            {
                if(description[i].value.length > 200)
                 {
                     pa.innerHTML = "<li>Description Should be Maximum of 200 Characters. ";
                     description[i].focus();
                     description[i].select();
                     return;
                 }

            }
        }
        if ( document.QuotationForm.quotation.value == 'Quotation')
            document.QuotationForm.quotation.value = 0


        if(action == 'UPDATE')
            document.QuotationForm.action.value = "UpdateQuotation";
        else if(action == 'SUBMIT')
            document.QuotationForm.action.value = "SubmitQuotation";

            document.QuotationForm.shippingAccount.disabled=false;
			enableCustPartNos();
            document.QuotationForm.submit();
    }

    function enableCustPartNos()
    {
        var custPNo = eval('document.QuotationForm.customerPartNo');
        if (custPNo.length ==  null )
        {
            custPNo.disabled = false;
        }
        else
        {
            for (var xx = 0; xx < custPNo.length; xx++ )
            {
                custPNo[xx].disabled = false;
            }
        }
    }

    function enableLabelNumbers()
    {
        var labelNo = eval('document.QuotationForm.labelNumber');
        if (labelNo.length ==  null )
        {
            labelNo.disabled = false;
        }
        else
        {
            for (var xx = 0; xx < labelNo.length; xx++ )
            {
                labelNo[xx].disabled = false;
            }
        }
    }

        function getComments(selecteditem)
       {
            var form = document.QuotationForm;
            var mfgPrtVal = form.manufacturingPartNo[selecteditem].value;
            var mfPartNo;
            var size;
            size = keys.length;
            var lineitems = count;

            if( lineitems > 2 )
            {
                mfPartNo = form.manufacturingPartNo[selecteditem].value;
                mfPartNo = trim(mfPartNo.toLowerCase());
			    for(i=0; i < size; i++)
                {
			        if( mfPartNo == trim(keys[i].toLowerCase()) && comments[i] != 'null')
                    {

                        form.lineItemDescription[selecteditem].value = comments[i];
                        //form.customerPartNo[selecteditem].value = customernos[i];
                        break;
                    }
                    else
                    {

                        form.lineItemDescription[selecteditem].value = "";
						//form.customerPartNo[selecteditem].value = "";
                    }

                }
                for(i=0; i < size; i++)
                {
                    if( mfPartNo == trim(keys[i].toLowerCase()))
                    {
                        var custPartNosOptions = form.customerPartNo[selecteditem].options;
                        var custPartNosOptionsLen = custPartNosOptions.length;
                        for(var l = custPartNosOptionsLen-1; l >=0; l--)
                        {
                             custPartNosOptions[l] = null;
                        }
                        custPartNosOptions[0] = new Option("Select Customer Part No","");

                        var tmpCustomerNos = customernos[i];
                        for( var k = 0; k < tmpCustomerNos.length; k++)
                        {
                            if( tmpCustomerNos[k] != '' )
                            {
                                custPartNosOptions[k+1] = new Option(tmpCustomerNos[k],tmpCustomerNos[k]);
                            }
                        }
                        custPartNosOptions[tmpCustomerNos.length+1] = new Option("--Add New CustomerPart No--","-2");
                        break;
                    }
                }
            }
            else
            {
                mfPartNo = form.manufacturingPartNo.value;
                mfPartNo = trim(mfPartNo.toLowerCase());

                for(j=0; j < size; j++)
                {
                    if( mfPartNo == trim(keys[j].toLowerCase()) && comments[j] != 'null')
                    {
                        form.lineItemDescription.value = comments[j];
                        break;
                    }
                    else
                    {
                        form.lineItemDescription.value = "";
                    }
                }//for
                for(i=0; i < size; i++)
                {
                    if( mfPartNo == trim(keys[i].toLowerCase()))
                    {
                        var custPartNosOptions = form.customerPartNo.options;
                        var custPartNosOptionsLen = custPartNosOptions.length;
                        for(var l = custPartNosOptionsLen-1; l >=0; l--)
                        {
                             custPartNosOptions[l] = null;
                        }
                        custPartNosOptions[0] = new Option("Select Customer Part No","");

                        var tmpCustomerNos = customernos[i];
                        for( var k = 0; k < tmpCustomerNos.length; k++)
                        {
                            if( tmpCustomerNos[k] != '' )
                            {
                                custPartNosOptions[k+1] = new Option(tmpCustomerNos[k],tmpCustomerNos[k]);
                            }
                        }
                        custPartNosOptions[tmpCustomerNos.length+1] = new Option("--Add New CustomerPart No--","-2");
                        break;
                    }
                }
            }
           showHideNewCustPartNo(selecteditem);
       }//fn
      var keys = new Array();
       var comments = new Array();
    <%
           java.util.HashMap mapComments = null;
           try{
                  mapComments = quotationFromMap.getMfgPartsWithComments();
                 java.util.Iterator mapKeyIterator = mapComments.keySet().iterator();
                 int count = 0;
                 strBuffer = new StringBuffer();
                 while( mapKeyIterator.hasNext() )
                 {
                     Object key = mapKeyIterator.next();
                     strBuffer.append("keys[").append(count).append("]='").append(key).append("';\n");
                     out.print( "comments["+count+"]='");
                     if(mapComments.get(key)!=null)
                     {
                        out.print(StringUtils.escapeSpecialString((String)mapComments.get(key)) );
                     }
                     out.println("';");
                     count++;
                 }
                out.println(strBuffer.toString());
              }
              catch(Exception ex)
              {

                  System.out.println(ex);
              }
        %>
        <%=ChangeOrderAction.getMapScript( quotationFromMap.getMfgPartsWithCustomerPartNos(), "customernos", false)%>
        //var keys1 = new Array();
        //var customernos = new Array();
        <%--
            //Added by Sarada 18th Jan 2004 to get Customer PartNos of selected mfg part nos
           java.util.HashMap mapCustPartNos = null;
           try{
               mapCustPartNos = quotationFromMap.getMfgPartsWithCustomerPartNos();
               java.util.Iterator mapKeyIterator = mapCustPartNos.keySet().iterator();
               int noCnt = 0;
               strBuffer1 = new StringBuffer();
                while( mapKeyIterator.hasNext() )
                 {
                     Object key = mapKeyIterator.next();
                     strBuffer1.append("keys[").append(noCnt).append("]='").append(key).append("';\n");
                     out.print( "customernos["+noCnt+"]='");
                     if(mapCustPartNos.get(key)!=null)
                     {
                        out.print(((String)mapCustPartNos.get(key)).replaceAll("'","\\\\" + "'") );
                     }
                     out.println("';");
                     noCnt++;
                 }
              out.println(strBuffer1.toString());

           }
          catch(Exception ex)
            {
            	System.out.println(ex);
            }
        --%>

        <%-- Added by varma (11 Dec 2004) --%>
        var labelnos = new Array();
        <%
           java.util.HashMap mapLabelNo = null;
           try{
               mapLabelNo = quotationFromMap.getMfgPartsWithLabelNumbers();
               java.util.Iterator mapKeyIterator = mapLabelNo.keySet().iterator();
               int noCnt = 0;
               strBuffer1 = new StringBuffer();
               while( mapKeyIterator.hasNext() )
               {
                     Object key = mapKeyIterator.next();
                     //strBuffer1.append("keysBaseOrderQty[").append(noCnt).append("]='").append(key).append("';\n");
                     out.print( "labelnos["+noCnt+"]='");
                     if(mapLabelNo.get(key)!=null)
                     {
                        out.print(((String)mapLabelNo.get(key)));
                     }
                     out.println("';");
                     noCnt++;
               }
           }
          catch(Exception ex)
            {
            	System.out.println(ex);
            }
        %>

function selectEndUser ()
{
    var endUserId = document.QuotationForm.endUserId.value;
    if(endUserId != -1 )
    {
        enableCustPartNos();//function
        document.QuotationForm.shippingAddress.disabled = false;
        document.QuotationForm.billingAddress.disabled = false;
        document.QuotationForm.action.value= 'loadEndUserDetails';
        document.QuotationForm.submit();
    }
}
function selectODM ()
{
    var odmId = document.QuotationForm.odmId.value;
    enableCustPartNos();//function
    document.QuotationForm.shippingAddress.disabled = false;
    document.QuotationForm.billingAddress.disabled = false;
    document.QuotationForm.action.value= 'loadODMDetails';
    document.QuotationForm.submit();

}
function showErrorReportPage()
{
    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
    newWindow.focus();
}

function selectCustomerSalesPersonRelation()
{
    var customerId = document.QuotationForm.customerId.value ;
    var customerName = document.QuotationForm.customerName.value;
    var odmId = document.QuotationForm.odmId.value;
    var LeftPos=(screen.width)?(screen.width-500)/2:100;
    var TopPos=(screen.height)?(screen.height-450)/2:100;
    newWindow = window.open ('<%=chipTracContext%>/customerSalesPersonRelationship.do?action=searchSalesPersons&customerId='+customerId+'&odmId='+odmId,'customerSalespersons','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=540,height=500,resizable=yes,Left= '+LeftPos+',top='+TopPos);
    if(!newWindow.opener) {newWindow.opener = window}
    newWindow.focus();
}

function addOptionToSelect(aName, aValue)
{
    var salesPersonObj = document.QuotationForm.salesPerson;

    addOption(salesPersonObj, aName + "", aValue, salesPersonObj.options.length);
    for( var i=0 ; i < salesPersonObj.options.length ; i++ )
    {
        if(salesPersonObj.options[i].value == document.QuotationForm.salesPersonName.value)
        {
            salesPersonObj.options[i].selected = true;
        }
    }
}

function addOption(aSelect, aName, aValue, anIndex)
{
   var aOption = new Option(aName, aValue)
   aSelect.options[anIndex] = aOption;
}

function deleteAllOptions()
{

    var salesPersonObj = document.QuotationForm.salesPerson;
    var optionValue1 = document.QuotationForm.salesPerson.value;

    if( typeof salesPersonObj !='undefined' )
    {
        for( var j = salesPersonObj.options.length ; j >= 0 ; j-- )
        {
             salesPersonObj.options[j] = null;
        }
    }
}
function setZeroPrice(no,lineno)
{
        if(document.QuotationForm.quantity.length != null)
        {
            var element = eval( document.QuotationForm["zeroPrice"+lineno] );
            if ( element.checked == true ) {
                document.QuotationForm.unitPriceAsDouble[no].value = "0.0";
                document.QuotationForm.unitPriceAsDouble[no].readOnly = true;
            }
            else
            {
                document.QuotationForm.unitPriceAsDouble[no].readOnly = false;
            }
        }
        else
        {
            if ( eval("document.QuotationForm.zeroPrice"+lineno).checked == true )
            {
                document.QuotationForm.unitPriceAsDouble.value = "0.0";
                document.QuotationForm.unitPriceAsDouble[no].readOnly = true;
            }
            else
            {
                   document.QuotationForm.unitPriceAsDouble[no].readOnly = false;
            }
        }
}
function reqPriceChanged( idx )
{
    var form = document.QuotationForm;
    var reqPriceCtrl = form.reqPrice;
    var priceCtrl = form.unitPriceAsDouble;
    if ( form.quantity.length != null )
    {
        if ( priceCtrl[idx].value == 0 )
        {
            priceCtrl[idx].value = reqPriceCtrl[idx].value;
        }
    }
    else
    {
        if ( priceCtrl.value == 0 )
        {
            priceCtrl.value = reqPriceCtrl.value;
        }
    }
}
function custResalePriceChanged( idx )
{
    var form = document.QuotationForm;
    var custResalePriceCtrl = form.custResalePrice;
    var suggResalePriceCtrl = form.suggResalePrice;
    if ( suggResalePriceCtrl != null )
    {
        if ( form.quantity.length != null )
        {
            if ( suggResalePriceCtrl[idx].value == 0 )
            {
                suggResalePriceCtrl[idx].value = custResalePriceCtrl[idx].value;
            }
        }
        else
        {
            if ( suggResalePriceCtrl.value == 0 )
            {
                suggResalePriceCtrl.value = custResalePriceCtrl.value;
            }
        }
    }
}
function showHideAddNewApplication ( )
{
    var form = document.QuotationForm;
    var applicationCtrl = form.application;
    var addNewApplicationCtrl = form.addNewApplication;
    var addNewApplicationLabelId = document.getElementById( "addNewApplicationLabelId" );
    var addNewApplicationId = document.getElementById ( "addNewApplicationId" );
    if ( applicationCtrl.value == "-2" )
    {
        addNewApplicationLabelId.style.display = 'block';
        addNewApplicationId.style.display = 'block';
    }
    else
    {
        addNewApplicationCtrl.value = "";
        addNewApplicationLabelId.style.display = 'none';
        addNewApplicationId.style.display = 'none';
    }
}
function editQuotationTypes()
{
    var form = document.QuotationForm;
    var quoteTypeCtrl = form.quoteType;
    if ( quoteTypeCtrl.value == "-2" )
    {
        editQuotePopupField( "QuoteType" );
    }
}
function editQuotePopupField( fieldType )
{
    if ( fieldType == 'QuoteApplication' )
    {
        var form = document.QuotationForm;
        form.application.value = -1;
        showHideAddNewApplication();
    }
    var LeftPos=(screen.width)?(screen.width-500)/2:100;
    var TopPos=(screen.height)?(screen.height-450)/2:100;
    newWindow = window.open ('<%=chipTracContext%>/quotePopupFieldsAction.do?action=load'+fieldType,fieldType,'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=540,height=500,resizable=yes,Left= '+LeftPos+',top='+TopPos);
    newWindow.focus();
}

function addOptionToList(listCtrl, aName, aValue)
{
   addOption(listCtrl, aName, aValue, listCtrl.options.length)
}

function deleteAllListOptions( listCtrl )
{
    if( typeof listCtrl !='undefined' )
    {
        for( var j = listCtrl.options.length ; j >= 0 ; j-- )
        {
             listCtrl.options[j] = null;
        }
    }
}
function resetForm()
{
    document.QuotationForm.reset();
    showHideAddNewApplication();
    showHideNewEndUserField();
    showHideNewCustPartNo(-1);
}
function showHideNewCustPartNo ( selectedIdx )
{
    var form = document.QuotationForm;
    if ( count > 2 )
    {
        if ( selectedIdx < 0 ) //All
        {
            for( var k = 0; k < form.customerPartNo.length; k++)
            {
                if ( form.customerPartNo[k].value == "-2" )
                {
                    form.newCustomerPartNo[k].style.display = "block";
                    form.newCustomerPartNo[k].focus();
                }
                else
                {
                    form.newCustomerPartNo[k].style.display = "none";
                }
            }
        }
        else
        {
            if ( form.customerPartNo[selectedIdx].value == "-2" )
            {
                form.newCustomerPartNo[selectedIdx].style.display = "block";
                form.newCustomerPartNo[selectedIdx].focus();
            }
            else
            {
                form.newCustomerPartNo[selectedIdx].style.display = "none";
            }
        }
    }
    else
    {
        if ( form.customerPartNo.value == "-2" )
        {
            form.newCustomerPartNo.style.display = "block";
            form.newCustomerPartNo.focus();
        }
        else
        {
            form.newCustomerPartNo.style.display = "none";
        }
    }
}

</SCRIPT>
</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload='check();'>

    <%
        String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
    %>
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>



<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
  <TBODY>
  <TR>

  <TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<%-- Side Navigation start --%>
<%
    String heading = "";

    if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0")))
    {
         heading = "Sample Order";
    }
    else if((request.getParameter("quotation") != null) && (request.getParameter("quotation").equals("0")))
    {
        heading = "Quote";
    }
    else
    {
        heading = "Sales Order";
    }
%>

        <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/sales_order_menu.jsp" %>
        </logic:equal>
        <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/ext_sales_order_menu.jsp" %>
        </logic:notEqual>

<%-- end of the side navigations --%>

  </TD>


<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<html:html>


<%-- from here your body starts --%>

<table width="65%" border="0"><tr><td ><center><span class="NArialW">Quote Entry</span></center></td></table>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>


   <table border="0" width="80%" align=right>
<% User user1 = (User) session.getAttribute (SessionKeys.USER_KEY);
      if( !user1.isActionAllowed (Functionality.SALES_NEW_QUOTATION,
      User.USER_ACTION_MODIFY ) ) { %>
        <tr><td colspan=7 align='left'>
        <font class='NArialS'>
		<font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b>
		</font></td></tr>
<% } %>


<html:form name="QuotationForm" action="/newQuotation" method="post" type="com.scalar.chiptrack.sales.forms.QuotationForm" >
<% QuotationForm quotationForm = (QuotationForm)request.getAttribute("QuotationForm"); %>
    <input type="hidden" name="quotation" value="<%=heading%>">
    <tr>
        <td><a name="#e1"></a></td>
    </tr>

	<tr>
        <td colspan=6 class="NArialL"><chiptrack:errors styleClass="NArialL" /></td>
    </tr>

    <tr>
        <td  colspan="6" align="left" class='NArialL'><FONT id="errors1" styleClass="NArialL" color='FF0000'></FONT></td>
    </tr>


    <tr>
	   <td width="12%"><font class="NArialL">Quote No :&nbsp;<font color=red>*</font></font></td>
       <td width="17%"><html:text name="QuotationForm" property="quotationNo" styleClass="txfield" size="23" maxlength="50" /></td>

       <td width="13%"><font class="NArialL">Customer Name :</font></td>
       <td width="20%" class="bodytext"><b><bean:write name="QuotationForm" property="customerName" /></b></td>

       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <logic:iterate name="screenDisplayFiledsList" id="fieldProperty" type="com.scalar.chiptrack.commons.FieldProperty" indexId="idx">
        <%
            if(idx.intValue()%2==0){
        %>
        <tr>
        <%
            }
        %>
        <logic:equal value="quoteType" property="fieldName" name="fieldProperty">
            <td width="12%"><font class="NArialL">Quote Type :<%= ConfigManager.isQuoteTypeMandatory() ? "&nbsp;<font color=red>*</font>" : "" %></font></td>
           <td width="17%">
                <html:select name="QuotationForm" property="quoteType"  styleClass="txfield" onchange="editQuotationTypes()">
                   <html:option value="-1">--- Select ---</html:option>
                   <html:options collection="quoteTypes" property="label" labelProperty="label" />
                   <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
                    <html:option value="-2">--- Edit ---</html:option>
                   </logic:equal>
               </html:select>
           </td>
        </logic:equal>
        <logic:equal value="application" property="fieldName" name="fieldProperty">
            <td width="13%"><font class="NArialL">Application :</font></td>
           <td width="20%" class="NArial">
               <html:select name="QuotationForm" property="application"  styleClass="txfield" onchange="showHideAddNewApplication()">
                   <html:option value="-1">--- Select ---</html:option>
                   <html:options collection="applications" property="label" labelProperty="label" />
                   <html:option value="-2">--- Add New ---</html:option>
               </html:select>
               <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
                &nbsp; <a class="leftsection" href="javascript:editQuotePopupField('QuoteApplication')" onmouseover="window.status='Click to Add/Edit Application Types';return true" onmouseout="window.status='';return true">Edit App</a>
               </logic:equal>
           </td>
        </logic:equal>
        <logic:equal value="projectName" property="fieldName" name="fieldProperty">
            <td width="13%"><font class="NArialL">Project Name :</font></td>
           <td width="20%" class="NArial">
               <html:text name="QuotationForm" property="projectName" size="23" styleClass="txfield"/>
           </td>
        </logic:equal>
        <logic:equal value="opportunityId" property="fieldName" name="fieldProperty">
            <td width="13%"><font class="NArialL">Opportunity ID :</font></td>
           <td width="20%" class="NArial">
               <html:text name="QuotationForm" property="opportunityId" size="23" styleClass="txfield"/>
           </td>
        </logic:equal>
        <%
            if(idx.intValue()%2==1){
        %>
            <td width="25%">&nbsp;</td>
           <td width="11%">&nbsp;</td>
        </tr>
        <%
            }
        %>
    </logic:iterate>

    <tr>
       <td width="12%"><font class="NArialL">&nbsp;</font></td>
       <td width="17%"></td>

       <td width="13%"><font class="NArialL" id="addNewApplicationLabelId" style="display:none;">Add New Application :</font></td>
       <td width="20%" class="NArial"><html:text name="QuotationForm" property="addNewApplication" styleClass="txfield" size="23" maxlength="50" style="display:none;" styleId="addNewApplicationId"/></td>

       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <tr>
       <td width="12%"><font class="NArialL"><bean:message key="label.sales.salesOrder.PoRevisionNumber"/> :</font></td>
       <td width="17%"><html:text name="QuotationForm" property="poRev" size="23" styleClass="txfield" /></td>
       <td width="13%"><font class="NArialL"><bean:message key="label.sales.salesOrder.PoDate"/> :</td>
       <td width="20%"><html:text name="QuotationForm" property="poDate" size="23" styleClass="txfield" />
       <a href="javascript:openCalendar(document.QuotationForm.poDate)"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
       </td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
     </tr>
    <tr>
       <td width="12%"><font class="NArialL"><bean:message key="label.sales.salesOrder.PoNumber"/>:&nbsp;</font></td>
       <td width="17%"><html:text name="QuotationForm" property="customerPO" styleClass="txfield" size="23" maxlength="50" onkeyup=""/></td>
       <td width="13%"><font class="NArialL"><bean:message key="label.sales.salesOrder.PoExpectedDate"/> :</td>
       <td width="20%"><html:text name="QuotationForm" property="expectedPoDate" size="23" styleClass="txfield" />
       <a href="javascript:openCalendar(document.QuotationForm.expectedPoDate)"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
       </td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
     </tr>
    <%--<tr><td colspan=4><font class="NArialL">Please <chiptrack:attachFile fileGroup="Quotation-PO" fileSubGroup="AUTO" formTitle="Attach Quotation PO" linkText="click here" allowAttach="true" allowDelete="true"/> to View and Attach PO</font></td></tr>--%>
    <tr>

       <td width="12%"><font class="NArialL"><bean:message key="label.sales.quotation.contactPerson"/> :</font></td>
       <td width="17%"><html:select  name="QuotationForm" property="contactPerson"  styleClass="txfield" onchange="javascript:selectContactPerson('CustomerContactPerson',0);">
	   <html:option value="">--- Select ---</html:option>
	   <html:options name="contactPersons" />
	   </html:select></td>
       <td width="13%">&nbsp;</td>
       <td width="20%">&nbsp;</td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>

    </tr>
    <tr>
       <td width="12%"><font class="NArialL">Phone :</font></td>
       <td width="17%"><html:text name="QuotationForm" property="phoneNumber" size="23" styleClass="txfield"  onkeypress='validatePhoneNumber(this)'/></td>
       <td width="13%"><font class="NArialL">Cell Phone No :</font></td>
       <td width="20%"><html:text name="QuotationForm" property="cellNumber" size="23" styleClass="txfield" onkeypress='validatePhoneNumber(this)'/></td>
       <td width="25%">&nbsp;</td>
	   <td width="11%">&nbsp;</td>
    </tr>
    <tr>
       <td width="12%"><font class="NArialL">Fax :</font></td>
       <td width="17%"><html:text name="QuotationForm" property="faxNumber" size="23" styleClass="txfield"  onkeypress='validatePhoneNumber(this)'/></td>
       <td width="13%"><font class="NArialL">Email :</font></td>
       <td width="20%"><html:text name="QuotationForm" property="email" size="23" styleClass="txfield" disabled="false" /></td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <tr>
       <td width="12%"><font class="NArialL"><bean:message key="label.sales.quotation.salesPerson"/> :</font></td>
      <td width="17%">
      <html:select name="QuotationForm" property="salesPerson" styleClass="txfield" >
            <html:option value="" >----- Select -----</html:option>
    	    <html:options collection="salesPersons" property="value" labelProperty="label"/>
        </html:select>
       <input type="hidden" name="salesPersonName" value="<%=quotationForm.getSalesPerson()%>"/>

        </td>
       <td width="13%"><font class="NArialL"><bean:message key="label.sales.salesRep.Name"/> :</font></td>
       <td width="20%">
        <html:select name="QuotationForm" property="salesRep" styleClass="txfield" >
            <html:option value="" >----- Select -----</html:option>
    	    <html:options collection="salesReps" property="value" labelProperty="label"/>
        </html:select>
        <input type="hidden" name="salesRep" value="<%=quotationForm.getSalesRep()%>" />

       </td>
       <td width="25%">&nbsp;</td>
	   <td width="11%">&nbsp;</td>

    </tr>

    <tr>
        <td colspan="3"><font class="NArialL">Please <a class="leftsection" href="javascript:selectCustomerSalesPersonRelation()" onmouseover="window.status='Click to select Customer/Relationship';return true" onmouseout="window.status='';return true">
        Click here</a>&nbsp;to Add Customer/<bean:message key="label.sales.quotation.salesPerson"/> Relationships
        </font></td>
        <td width="8%">&nbsp;</td>
        <td width="20%">&nbsp;</td>
    </tr>

    <tr>
       <td width="12%"><font class="NArialL"><bean:message key="label.sales.salesOrder.ShippingMethod" /> :</font></td>
       <td width="17%">
	   	   <select name="shippingMethod" class="txfield" onchange="javascript:addShippingMethod(this);">
		   <option value="-1" >----- Select -----</option>

		   <% java.util.ArrayList shippingMethods = null;
                
                 boolean flagValue = false;
               try
               {
                 if(request != null)
                 {
                      selectedMethod = (String)request.getAttribute("Method");
                      selectedAccount = (String)request.getAttribute("Account");
					  shippingMethods = quotationFromMap.getShippingMethods();
                      org.apache.struts.util.LabelValueBean shippingMethod;
                     for(int j=0; j<shippingMethods.size(); j++)
                     {
                         shippingMethod = (org.apache.struts.util.LabelValueBean)shippingMethods.get(j);
                         String label = shippingMethod.getLabel();
                         String value = shippingMethod.getValue();

                         if( selectedMethod != null)
                         {
							if( (selectedMethod.trim()).equalsIgnoreCase(label.trim()) )
							{ %>
								<option value="<%=selectedMethod%>" selected><%=selectedMethod%></option>
						  <%} else if ( "'".equalsIgnoreCase(value)) {  %>
                                <option value="-1" ><%=label%></option>
                          <%} else {%>
								<option value="<%=label%>" ><%=label%></option>
						  <%}
                        } else { %>
						     <option value="<%=label%>" ><%=label%></option>
					  <%}

                    }//for
                 }//if
               } catch(NullPointerException e) { e.printStackTrace();}
			%>

            <option value="-2" >----- Edit -----</option>
            </select>
	   </td>

        <td width="13%">&nbsp;</td>
	    <td width="20%">
            <input type="hidden" name="shippingAccount" value="<%=quotationForm.getShippingAccount()%>"/>
        </td>


       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <tr>
       <td width="12%"><font class="NArialL" id="newshippingMethod"><bean:message key="label.sales.salesOrder.NewShippingMethod"/>:</font></td>
       <td width="17%"><html:text name="QuotationForm" property="newshippingMethod" size="23" maxlength="50" styleClass="txfield" /></td>
       <td width="13%"><font class="NArialL" id="newshippingAccount"><bean:message key="label.sales.salesOrder.NewShippingAccount"/>:</font></td>
       <td width='20%'><html:text name="QuotationForm" property="newshippingAccount" size="23" maxlength="50" styleClass="txfield"/></td>
       <td width="25%">&nbsp;</td>
       <td width='11%'>&nbsp;</td>
    </tr>
    <tr>
       <td width="12%"><font class="NArialL">Pay Terms :</font></td>
       <td width="17%"  >
            <html:select name="QuotationForm" property="shippingTerms" styleClass="txfield" onchange="javascript:AddShippingTerms()">
                <option value="" >----- Select -----</option>
           <html:options name="allShippingTerms" />
		   <html:option value="-2" >-- Add New Pay Terms --</html:option>
           </html:select>
        </td>


       <td width="13%"><font class="NArialL"><bean:message key="label.sales.salesOrder.DeliveryTerms" /> :</font></td>
       <td width="20%">
           <html:select name="QuotationForm" property="deliveryTerms" styleClass="txfield" onchange="javascript:AddDeliveryTerms()">
               <option value="" >----- Select -----</option>
               <html:options name="allDeliveryTerms"/>
               <html:option value="-2">-- Add New <bean:message key="label.sales.salesOrder.DeliveryTerms" /> --</html:option>
            </html:select>
       </td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <tr>
       <td width="12%"><font class="NArialL" id="newShippingTerms">New Pay Terms:</font></td>
	   <td width="17%"><html:text name="QuotationForm" property="newShippingTerms" size="23" maxlength="50" styleClass="txfield" /></td>
       <td width="13%"><font class="NArialL" id="newDeliveryTerms">New <bean:message key="label.sales.salesOrder.DeliveryTerms" />:</font></td>
       <td width="20%"><html:text name="QuotationForm" property="newDeliveryTerms" size="23" maxlength="50" styleClass="txfield" /></td>
       <td width='25%'></td>
       <td width='11%'>&nbsp;</td>
	 </tr>
    <tr>
       <td width="12%"><font class="NArialL"><bean:message key="label.sales.quotation.regionalRep"/> :</font></td>
       <td width="17%"> <html:text name="QuotationForm" property="regionalRep" size="23" styleClass="txfield" /></td>
       <td width="13%"><font class="NArialL">Quote Date :</font></td>
       <td width='20%'><html:text name="QuotationForm" property="quotationDate" size="23" styleClass="txfield" disabled="true"/>
       <td width="25%">&nbsp;</td>
       <td width='11%'>&nbsp;</td>
    </tr>
    <tr>
       <td width="13%"><font class="NArialL"><bean:message key="label.sales.endUser"/> :&nbsp;<font color=red>*</font></font></td>
       <td width="18%">
        <html:select name="QuotationForm" property="endCustomerId" styleClass="txfield" onchange="showHideNewEndUserField()">
            <html:option value="" >----- Select -----</html:option>
    	    <html:options collection="endCustomerList" property="value" labelProperty="label"/>
            <html:option value="-2" >-----Add New-----</html:option>
        </html:select>
        <html:hidden name="QuotationForm" property="endCustomer" />
        <input type="hidden" name="endUser" value="" />
       </td>
       <td width="15%"><font class="NArialL"><bean:message key="label.sales.shipToCustomer"/>:&nbsp;<font color=red>*</font></font></td>
       <td width="20%">
          <html:select name="QuotationForm" property="odmId" styleClass="txfield" onchange="javascript:getCustomerShippingAddress();"> <%--onchange="javascript:selectODM(this);"--%>
            <html:option value="-1" >----- Select -----</html:option>
            <html:options collection="odmList" property="value" labelProperty="label"/>
            <html:option value="-2" >-----Add New-----</html:option>
          </html:select>
        <html:hidden name="QuotationForm" property="odm" />
        </td>
       <td width="22%">&nbsp;</td>
       <td width="11%">&nbsp;</td>

     </tr>
     <tr>
       <td class="NArialL"><span id="endUserLabelSpan" style="display:none"> New <bean:message key="label.sales.endUser"/> :</span></td>
       <td ><span id="endUserTxfieldSpan" style="display:none"><html:text name="QuotationForm" property="newEndUserName" styleClass="txfield"/></span></td>
       <td class="NArialL"><span id="endCustomerLabelSpan" style="display:none"> New <bean:message key="label.sales.shipToCustomer"/>:</span></td>
       <td ><span id="endCustomerTxfieldSpan" style="display:none"><html:text name="QuotationForm" property="newEndCustomerName" styleClass="txfield"/></span></td>

       <td width="22%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>

    <tr>
       <td width="12%">&nbsp;</td>
       <td width="17%">&nbsp;</td>
       <td width="13%"><font class="NArialL"><bean:message key="label.sales.shipToCustomer"/> Shipping Address :</font></td>
       <td width="20%">
       <html:checkbox name="QuotationForm" property="isEndCustomerShipAddress" value="true" styleClass="txfield" onclick="javascript:getEndCustomerShippingAddress(this);" />
       </td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>


    <tr>
       <td width="12%">&nbsp;</td>
       <td width="17%">&nbsp;</td>
       <td width="13%"><font class="NArialL">Shipping Addresses :</font></td>
       <td width="20%">
          <html:select name="QuotationForm" property="shippingAddressId" styleClass="txfield" onchange="javascript:assignShippingAddress(this);">
            <%--<html:option value=""/>--%>
            <html:options collection="shippingAddresses" property="value" labelProperty="label"/>
          </html:select>
       </td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <tr>
       <td width="12%"><font class="NArialL"><bean:message key="label.sales.quotation.billingContactPerson"/> :</font></td>
       <td width="17%"><html:select  name="QuotationForm" property="billingContactPerson"  styleClass="txfield" onchange="javascript:selectContactPerson('BillingContactPerson',0,0);" >
	   <html:option value="">--- Select ---</html:option>
	   <html:options name="billingAddressContactPersons" />
	   </html:select></td>
       <td width="13%"><font class="NArialL"><bean:message key="label.sales.quotation.shippingContactPerson"/>  :</font></td>
       <td width="20%">
	   <html:select  name="QuotationForm" property="shippingContactPerson"  styleClass="txfield" onchange="javascript:selectContactPerson('ShippingContactPerson',0,0);">
	   <html:option value="">--- Select ---</html:option>
	   <html:options name="shippingAddressContactPersons" />
	   </html:select>
	   </td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <tr>
       <td width="12%"><font class="NArialL">Billing Address :</font></td>
       <td width="17%"><html:textarea rows="13" name="QuotationForm" property="billingAddress" cols="23" styleClass="txfield" disabled="true"/></td>
       <td width="13%"><font class="NArialL">Shipping Address :</font></td>
       <td width="20%">
            <html:link styleClass="NArialL" href="javascript:AddNewShippingAddress(document.QuotationForm.shippingAddress);" onmouseover="window.status='Click to Add New Shipping Address';return true"  onmouseout="window.status='';return true">Add new shipping Address</html:link>
            <br>
        <html:textarea name="QuotationForm" rows="13" cols="23" property="shippingAddress" styleClass="txfield" disabled="true"/>
       </td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <tr>
        <td colsapn=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
    </tr>
    <tr>
       <td width="13%"><font class="NArialL">All Freight Instructions :</font></td>
       <td width="20%">
          <html:select name="QuotationForm" property="freightInstructionsId" styleClass="txfield" onchange="javascript:assignFreightInstructions(this);">
            <html:options collection="freightInstructions" property="value" labelProperty="label"/>
          </html:select>
        </td>
       <td width="13%"><font class="NArialL">All Shipping Instructions :</font></td>
       <td width="20%">
          <html:select name="QuotationForm" property="shippingInstructionsId" styleClass="txfield" onchange="javascript:assignShippingInstructions(this);">
            <html:options collection="shippingInstructions" property="value" labelProperty="label"/>
          </html:select>
        </td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <tr>
       <td width="13%"><font class="NArialL" id="freightInstructionLabel">Freight Instructions :</font></td>
       <td width="20%"><html:textarea name="QuotationForm" property="freightInstructions" rows="4" cols="35" styleClass="txfield" onkeydown="javascript:setTextAreaMaxLength(document.QuotationForm.freightInstructions,300)" onkeyup="javascript:setTextAreaMaxLength(document.QuotationForm.freightInstructions,300)"/></td>
       <td width="13%"><font class="NArialL" id="shippingInstructions"><bean:message key="label.sales.shippingInstructions" /></font></td>
       <td width="20%"><html:textarea name="QuotationForm" property="shippingInstructions" rows="4" cols="35" styleClass="txfield" onkeydown="javascript:setTextAreaMaxLength(document.QuotationForm.shippingInstructions,300)" onkeyup="javascript:setTextAreaMaxLength(document.QuotationForm.shippingInstructions,300)"/></td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <script>setReadOnlyForFreightInsructions ( document.QuotationForm.freightInstructionsId );</script>
    <tr>
        <td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td>
    </tr>
    <tr>
       <td width="12%"><font class="NArialL">Quotation Expires On :&nbsp;<font color=red>*</font></font></td>
       <td width="17%"><html:text name="QuotationForm" property="expiryDate" size="23" styleClass="txfield" />
       <a href="javascript:openCalendar(document.QuotationForm.expiryDate)"><img onmouseover="window.status='Click to Select Date';return true" title="Click here to Select Date" onmouseout="window.status='';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
       </td>
       <td width="12%">&nbsp;</td>
       <td width="17%">&nbsp;</td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
    </tr>
    <tr>
       <td width="12%" class="NArialL">Comments :</td>
       <td width="87%" colspan="5">
            <html:textarea name="QuotationForm" rows="4" property="comments" cols="100" styleClass="txfield" onkeydown="javascript:setTextAreaMaxLength(document.QuotationForm.comments,300)" onkeyup="javascript:setTextAreaMaxLength(document.QuotationForm.comments,300)"/>
       </td>
    </tr>
    <%
        //String commentsGroupId = "Quotation-" + quotationForm.getQuotationNo();
    %>
    <tr><td colspan=4><chiptrack:internalComments commentsGroupId="AUTO"/></td></tr>

    <tr>
       <td width="12%">&nbsp;</td>
       <td width="17%">&nbsp;</td>
       <td width="13%">&nbsp;</td>
       <td width="20%">&nbsp;</td>
       <td width="25%">&nbsp;</td>
       <td width="11%">&nbsp;</td>
     </tr>
    <tr>
        <td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td>
    </tr>
    <tr>
        <td colspan='6' align="left" class='NArialL'><FONT id="errors" styleClass="NArialL" color='FF0000'></FONT></td>
    </tr>
    <tr>
        <td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td>
    </tr>
    <tr>
        <td colspan=6>
            <br><font class="NArialS" color='blue'><b><li>&nbsp;Select the zero price option if you want to keep the price as zero.</b></font>
            <br><br>
        <%int additionalColumns=0;%>
        <table border="0" width="95%" id="lineItemsTable">
	    <tr>
	        <td width="8%"  align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Line Item</font></td>
            <td width="8%"  align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">PO Line Item&nbsp;*</font></td>
            <td width="20%" align="center" bgcolor="#993333" class="NArialL">
			<font color="#FFFFFF"><bean:message key="label.mfgPartNumber" />&nbsp;*</font>
			</td>
            <td width="20%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
				<bean:message key="label.customerPartNumber"/>
			</font></td>
            <td width="15%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Description</font></td>
            <td width='1%'  align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Taxable</font></td>
            <td width="14%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Req'd Dock Date<br><font size="-3">(mm/dd/yyyy)</font>&nbsp;*</font></td>
	        <td width="5%"  align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Lead Time&nbsp;</font></td>
            <td width="5%"  align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Quantity&nbsp;*</font></td>
            <%
                if(ConfigManager.isShowQuoteMinOrderQty()) {
                    additionalColumns++;
            %>
                <td width="5%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Min Order Quantity</font></td>
            <%
                }
            %>
            <logic:equal value="true" name="QuotationForm" property="distributor">
                <%
                    if ( ConfigManager.isShowQuoteRequestedPrice() )
                    {
                        additionalColumns++;
                %>
                        <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.requestedPrice"/></font></td>
                <%
                    }
                    if ( ConfigManager.isShowQuoteCustResalePrice() )
                    {
                        additionalColumns++;
                %>
                        <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.customerResalePrice"/></font></td>
                <%
                    }
                %>
            </logic:equal>
            <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.price"/></font></td>
            <logic:equal value="true" name="QuotationForm" property="distributor">
                <%
                    if ( ConfigManager.isShowQuoteSuggResalePrice() )
                    {
                        additionalColumns++;
                %>
                        <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.suggestedResalePrice"/></font></td>
                <%
                    }
                %>
            </logic:equal>
            <td width="15%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Amount</font></td>
            <td width="15%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">&nbsp;Zero&nbsp;<br>&nbsp;Price&nbsp;</font></td>
        </tr>
<logic:iterate id="myHashMap" name="lineItemsWithSubtotals">
    <logic:iterate id="lineItemList" name="myHashMap" >
          <logic:iterate id="LineItem" name="lineItemList" property="key" type="com.scalar.chiptrack.sales.LineItem">
        <tr>
	        <td width="8%" bgcolor="#DEE1E2">
                <html:text name="LineItem" property="lineItemNo" size='6' styleClass="txfield" disabled="true"/>
                <input type="hidden" name="lineItemNo" value="<%=LineItem.getLineItemNo()%>" />
                <input type="hidden" name="jsLineItemNo" value="<%=LineItem.getLineItemNo()%>">
            </td>
            <td width="8%" bgcolor="#DEE1E2">
                <html:text name="LineItem" property="poLineItemNo" size='6' styleClass="txfield" disabled="true"/>
                <input type="hidden" name="poLineItemNo" value="<%=LineItem.getPoLineItemNo()%>"/>
            </td>
            <td width="18%" bgcolor="#DEE1E2">
                <select name="manufacturingPartNo" class="txfield" onChange="javascript:getComments(<%=i%>)">
                <option value="" >Select Part Number</option>
                <%
                      strBuffer1 = new StringBuffer();
                      for(int k=0;k<mfgList.size();k++)
                      {
                            customerPartNo = (CustomerPartNumber)mfgList.get(k);

							if( (customerPartNo.getManufacturingPartNo()).equalsIgnoreCase(LineItem.getManufacturingPartNo()) )
							{
								strBuffer1.append("<option value='").append(customerPartNo.getManufacturingPartNo()).append("'selected>");
							}
							else
							{
								strBuffer1.append("<option value='").append(customerPartNo.getManufacturingPartNo()).append("'>");
							}
							strBuffer1.append(customerPartNo.getManufacturingPartNo()).append("</option>\n");
                      }
                       out.println(strBuffer1);

                %>
            </select>
			<% i = i + 1; %>
            </td>
			<td width="20%" bgcolor="#DEE1E2"><font class="NArialL">

            <select name="customerPartNo"  class="txfield" onchange="javascript:showHideNewCustPartNo(<%=m%>)">
                 <option value="">Select Customer Part No</option>
                 <%
                      ArrayList customerPartNumbersList = (ArrayList)request.getAttribute( "customerPartNumbers"+LineItem.getLineItemNo());
                      if ( customerPartNumbersList != null )
                      {
                          StringBuffer strBuffer2 = new StringBuffer();
                          for ( int j = 0; j < customerPartNumbersList.size(); j++) {
                              String customerPartNumber =  (String)customerPartNumbersList.get(j);
                              if( (customerPartNumber).equalsIgnoreCase(LineItem .getCustomerPartNo()) )
                              {
                                  strBuffer2.append("<option value='").append(customerPartNumber).append("'selected>");
                              }
                              else
                              {
                                  strBuffer2.append("<option value='").append(customerPartNumber).append("'>");
                              }
                              strBuffer2.append(customerPartNumber).append("</option>\n");
                          }
                          out.println(strBuffer2);
                      }
               %>
               <option value="-2" <%="-2".equals(LineItem .getCustomerPartNo()) ? "selected" : ""%> >--Add New CustomerPart No--</option>
             </select>
                <% m = m + 1; %>
               <html:text name="LineItem" property="newCustomerPartNo" style="display:none;" styleClass="txfield" maxlength="50" size="20"/> 
            </td>
            <td width="15%" bgcolor="#DEE1E2">
                <input type="hidden" name="">
                <font class="NArialL">
                   <html:textarea name="LineItem" property="lineItemDescription"  styleClass="txfield" onkeydown="javascript:setTextAreaMaxLength(this,200)" onkeyup="javascript:setTextAreaMaxLength(this,200)" />
                </font>
           </td>
            <td width="5%" bgcolor="#DEE1E2" align=center>
                 <%if( LineItem.getIsTaxable() ){%>
                 <input type="checkbox" name=isTaxable<bean:write name="LineItem" property="lineItemNo"/> value="on" CHECKED>
                 <%}else{%>
                    <input type="checkbox" name=isTaxable<bean:write name="LineItem" property="lineItemNo"/> value="on">
                <%}%>
           </td>
            <td width="20%" bgcolor="#DEE1E2" nowrap>
                <html:text name="LineItem" property="requestDate" size='15' styleClass="txfield"/>
                <a href="javascript:if(document.QuotationForm.requestDate.length!=null){openCalendar(document.QuotationForm.requestDate[<bean:write name="LineItem" property="lineItemNo"/>-1])}else{openCalendar(document.QuotationForm.requestDate)}"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
            </td>
             <td width="5%" bgcolor="#DEE1E2">
                <html:select  name="LineItem" property="leadTime"  styleClass="txfield">
                    <html:option value="0">Select Lead Time</html:option>
                    <html:optionsCollection value="value" name="LineItem" property="leadTimeList" label="label"/>
                </html:select>

            </td>
            <td width="5%" bgcolor="#DEE1E2">
                <html:text name="LineItem" property="quantity"  size='8' styleClass="valuetxfield" onkeypress="javascript:allowInteger()"  maxlength="6"/>
                <input type="hidden" name="oldQty" value="<%=LineItem.getQuantity()%>">
            </td>
            <%
                if(ConfigManager.isShowQuoteMinOrderQty()) {
            %>
                <td width="5%" bgcolor="#DEE1E2">
                    <html:text name="LineItem" property="minOrderQty"  size='8' styleClass="valuetxfield" onkeypress="javascript:allowInteger()"  maxlength="6"/>
                </td>
            <%
                }
            %>
            <logic:equal value="true" name="QuotationForm" property="distributor">
                <%
                    if ( ConfigManager.isShowQuoteRequestedPrice() )
                    {
                        String reqPriceOnChangeScript = "reqPriceChanged(" + (i-1) + ")";
                %>
                        <td width="10%" bgcolor="#DEE1E2"><html:text name="LineItem" property="reqPrice" size='12' styleClass="valuetxfield" onkeypress="<%=restrictCharsJSFnc2%>" onchange="<%=reqPriceOnChangeScript%>" maxlength="9" /></td>
                <%
                    }
                    if ( ConfigManager.isShowQuoteCustResalePrice() )
                    {
                        String custResalePriceOnChangeScript = "custResalePriceChanged(" + (i-1) + ")";
                %>
                        <td width="10%" bgcolor="#DEE1E2"><html:text name="LineItem" property="custResalePrice" size='12' styleClass="valuetxfield" onkeypress="<%=restrictCharsJSFnc2%>" maxlength="9" onchange="<%=custResalePriceOnChangeScript%>"/></td>
                <%
                    }
                %>
            </logic:equal>
            <td width="10%" bgcolor="#DEE1E2">
                <html:text name="LineItem" property="unitPriceAsDouble" size='12' styleClass="valuetxfield" onkeypress="<%=restrictCharsJSFnc%>" maxlength="9" onkeyup="<%=restrictAmtJSFnc%>"/>
            </td>
            <logic:equal value="true" name="QuotationForm" property="distributor">
                <%
                    if ( ConfigManager.isShowQuoteSuggResalePrice() )
                    {
                %>
                        <td width="10%" bgcolor="#DEE1E2"><html:text name="LineItem" property="suggResalePrice" size='12' styleClass="valuetxfield" onkeypress="<%=restrictCharsJSFnc%>" maxlength="9" onkeyup="<%=restrictAmtJSFnc%>"/></td>
                <%
                    }
                %>
            </logic:equal>
            <td width="15%" bgcolor="#DEE1E2">
                <html:text name="LineItem" property="amountAsString" size='25' styleClass="valuetxfield" disabled="true"/>
            </td>
            <td width="15%" bgcolor="#DEE1E2" align="center">
                <%if( LineItem.getZeroPrice() ){%>
                    <input type="checkbox" name=zeroPrice<bean:write name="LineItem" property="lineItemNo"/> value="on" onClick="javascript:setZeroPrice( <%=(i-1)%>,  <%=LineItem.getLineItemNo()%> )" CHECKED>
                <%}else{%>
                    <input type="checkbox" name=zeroPrice<bean:write name="LineItem" property="lineItemNo"/> value="on" onClick="javascript:setZeroPrice( <%=(i-1)%>,  <%=LineItem.getLineItemNo()%> )">
                    <%}%>
            </td>
        </tr>
        </logic:iterate>

        <logic:notEqual parameter="action" value="NewQuotation">
           <logic:notEqual parameter="action" value="SearchCustomer">

            <tr>
                <bean:define id="subTotal" name="lineItemList" property="value" type="com.scalar.chiptrack.sales.SubTotal"/>
                <td colspan="8" width="15%" bgcolor="#FFFFFF" class="NArialL" align="right">
                    Sub Total
                </td>
                <td colspan="1" width="15%" bgcolor="#FFFFFF" class="NArialL" align="right">
                    <bean:write name="subTotal" property="subTotalQty" />
                </td>
                <td>&nbsp;</td>
                <td colspan="<%=(1+additionalColumns)%>" width="15%" bgcolor="#FFFFFF" class="NArialL" align="right">
                    <bean:write name="subTotal" property="subTotalAmt" />
                </td>
            </tr>
             </logic:notEqual>
      </logic:notEqual>
   </logic:iterate>
</logic:iterate>
            <tr id="rowIndex"><td colspan='11' align="left"><FONT id="font1"></FONT></TD></TR>
            <tr><td colspan="11">&nbsp;</td></tr>
            <tr>
            <td colspan="<%=(10+additionalColumns)%>" align="right" bgcolor="#FFFFFF" class="NArialL">Total</td>
            <td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;<html:text name="QuotationForm" property="subTotalAsString" disabled="true" styleClass="valuetxfield" size="25"/></td>
            <td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
        </tr>
        <tr>
            <td colspan="3" class="NArialL" align=right>Sales Tax State</td>
            <td class="NArialL">
                <html:select name="QuotationForm" property="salesTaxType" styleClass="txfield" onchange="javascript:addNewSalesTaxType(this);">
	            <html:option value="0" >Non Taxable</html:option>
	            <html:options collection="salesTaxes" property="value" labelProperty="label" />
	            <html:option value="-1">Others</html:option>
                </html:select>
            </td>
            <td colspan="<%=(6+additionalColumns)%>" align=right class="NArialL">Sales Tax</td>
            <td width="15%" class="NArialL" >&nbsp;&nbsp;<html:text name="QuotationForm" property="salesTaxAsString" styleClass="valuetxfield"  size="25" disabled="true"/></td>
            <td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
        </tr>
        <tr>
            <td colspan=3 align=right class="NArialL"><font class="NArialL"><FONT id="font-1"></FONT></font></td>
            <td class="NarialL" ><font class="NArialL"><FONT id="font-2"></FONT></font></td>
            <td colspan="3" class="NArialL">&nbsp;</td>
            <td colspan="<%=(3+additionalColumns)%>" align=right class="NArialL">Freight</td>
            <td width="15%" class="NArialL">$<html:text name="QuotationForm" property="frieghtAsDouble" styleClass="valuetxfield"  size="25" maxlength="9" onkeypress="<%=restrictCharsJSFnc%>" onkeyup="<%=restrictAmtJSFnc%>"/></td>
            <td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
        </tr>
        <tr>
            <td colspan=3 align=right class="NArialL"><font class="NArialL"><FONT id="font-3"></FONT></font></td>
            <td class="NarialL" ><font class="NArialL"><FONT id="font-4"></FONT></font></td>
            <td colspan="3" class="NArialL">&nbsp;</td>
            <td colspan="<%=(3+additionalColumns)%>" align=right class="NArialL"><html:text name="QuotationForm" property="miscName" styleClass="valuetxfield"/></td>
            <td width="15%" class="NArialL">$<html:text name="QuotationForm" property="miscAsDouble" styleClass="valuetxfield" size="25" maxlength="9" onkeypress="<%=restrictCharsJSFnc%>" onkeyup="<%=restrictAmtJSFnc%>"/></td>
            <td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
        </tr>
        <tr>
            <td colspan="<%=(10+additionalColumns)%>" align=right class="NArialL">Order Total</td>
            <td width="15%" class="NArialL">&nbsp;&nbsp;<html:text name="QuotationForm" property="orderTotalAsString" disabled="true" styleClass="valuetxfield" size="25"/></td>
            <td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
        </tr>

        <tr><td colspan="11">&nbsp;</td></tr>

        <tr>
            <td colspan="<%=(9+additionalColumns)%>">&nbsp</td>
            <td align="center"><a href="javascript:addTextArea();" onmouseover="window.status='Click to Add LineItem';return true" title="Click here to Add LineItem" onmouseout="window.status='';return true"><img src="<%=chipTracContext%>/jsp/includes/images/addmore.gif" border=0></a></td>
            <td width="15%" align="center"><chiptrack:restrictedLink functionality='<%=Functionality.SALES_NEW_QUOTATION%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('UPDATE');" onmouseover="window.status='Click here to Calculate Order Total';return true" onmouseout="window.status='';return true"><img src="<%=chipTracContext%>/jsp/includes/images/calculate.gif" title='Click here to Calculate Order total' border='0'></chiptrack:restrictedLink></td>
            <td width="15%" align="center" bgcolor="#FFFFFF">&nbsp;</td>
        </tr>

        </table>
        </td>
    </tr>


    <tr>
        <td colspan=6 align=center>
            <chiptrack:restrictedLink functionality='<%=Functionality.SALES_NEW_QUOTATION%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('SUBMIT');" onmouseover="window.status='Click here to save new Quote';return true" onmouseout="window.status='';return true">
            <img src="<%=chipTracContext%>/jsp/includes/images/submit.gif" title='Click here to save new Quote' border='0'></chiptrack:restrictedLink>

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="javascript:resetForm();" onmouseover="window.status='Click to Reset Values';return true" title="Click here to Reset" onmouseout="window.status='';return true" ><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0'></a>
        </td>
    </tr>

    </table>
    <input type="hidden" name="quotationType"  value="<%= quotationForm.getQuotationType() %>">
    <input type="hidden" name="currentPrice" value="<%= quotationForm.getCurrentPrice() %>">
    <input type="hidden" name="currentPriceUnits" value="<%= quotationForm.getCurrentPriceUnits() %>">
    <input type="hidden" name="currentPriceUnitsType" value="<%= quotationForm.getCurrentPriceUnitsType() %>">
    <input type="hidden" name="currentPriceOthers" value="<%= quotationForm.getCurrentPriceOthers() %>">
    <input type="hidden" name="targetPrice" value="<%= quotationForm.getTargetPrice() %>">
    <input type="hidden" name="targetPriceUnitsType" value="<%= quotationForm.getTargetPriceUnitsType() %>">
    <input type="hidden" name="targetPriceUnits" value="<%= quotationForm.getTargetPriceUnits() %>">
    <input type="hidden" name="targetPriceOthers" value="<%= quotationForm.getTargetPriceOthers() %>">
    <input type="hidden" name="historyPricesInfo" value="<%= quotationForm.getHistoryPricesInfo() %>">
    <input type="hidden" name="contractPriceFlag" value="<%= quotationForm.isContractPriceFlag() %>">
    <%--<input type="hidden" name="contractPriceFilePath" value="<%= quotationForm.getContractPriceFilePath() %>">--%>
    <input type="hidden" name="contractPriceChangedReason" value="<%= quotationForm.getContractPriceChangedReason() %>">
    <input type="hidden" name="previousCommitments" value="<%= quotationForm.getPreviousCommitments() %>">
    <input type="hidden" name="previousCommitmentsPrice" value="<%= quotationForm.getPreviousCommitmentsPrice() %>">
    <input type="hidden" name="commitmentAddtionalInfo" value="<%= quotationForm.getCommitmentAddtionalInfo() %>">
    <input type="hidden" name="previousQuotation" value="<%= quotationForm.isPreviousQuotation() %>">
    <input type="hidden" name="previousQuotationDetails" value="<%= quotationForm.getPreviousQuotationDetails() %>">
    <%--<input type="hidden" name="priceDiscountReason" value="<%= quotationForm.getPriceDiscountReason() %>">--%>
    <input type="hidden" name="contractPriceFileName" value="<%= quotationForm.getContractPriceFileName() %>">

    <%  
       if( quotationForm.getPriceDiscountReason() != null && quotationForm.getPriceDiscountReason().length > 0 )
        {
        for( int j=0; j<quotationForm.getPriceDiscountReason().length; j++ )
        {
            %>
             <input type="hidden" name="priceDiscountReason" value="<%= quotationForm.getPriceDiscountReason()[j] %>">
    <%
        }
        }
    %>
    <input type="hidden" name="priceDiscountComments" value="<%= quotationForm.getPriceDiscountComments() %>">
    <input type="hidden" name="rebate" value="<%= quotationForm.isRebate() %>">
    <input type="hidden" name="rebateValue" value="<%= quotationForm.getRebateValue() %>">
    <input type="hidden" name="rebateOpertunity" value="<%= quotationForm.getRebateOpertunity() %>">
    <input type="hidden" name="rebateGoal" value="<%= quotationForm.getRebateGoal() %>">
    <input type="hidden" name="rebateTarget" value="<%= quotationForm.getRebateTarget() %>">
    <input type="hidden" name="rebateTargetValue" value="<%= quotationForm.getRebateTargetValue() %>">
    <input type="hidden" name="rebateVerifiedBy" value="<%= quotationForm.getRebateVerifiedBy() %>">
    <input type="hidden" name="competatior1" value="<%= quotationForm.getCompetatior1() %>">
    <input type="hidden" name="competatior1Others" value="<%= quotationForm.getCompetatior1Others() %>">
    <input type="hidden" name="competatior1Price" value="<%= quotationForm.getCompetatior1Price() %>">
    <input type="hidden" name="competatior1PriceUnit" value="<%= quotationForm.getCompetatior1PriceUnit() %>">
    <input type="hidden" name="competatior1Comments" value="<%= quotationForm.getCompetatior1Comments() %>">
    <input type="hidden" name="competatior2" value="<%= quotationForm.getCompetatior2() %>">
    <input type="hidden" name="competatior2Others" value="<%= quotationForm.getCompetatior2Others() %>">
    <input type="hidden" name="competatior2Price" value="<%= quotationForm.getCompetatior2Price() %>">
    <input type="hidden" name="competatior2PriceUnit" value="<%= quotationForm.getCompetatior2PriceUnit() %>">
    <input type="hidden" name="competatior2Comments" value="<%= quotationForm.getCompetatior2Comments() %>">
    <input type="hidden" name="distributorMargin" value="<%= quotationForm.getDistributorMargin() %>">
    <input type="hidden" name="marginDollars" value="<%= quotationForm.getMarginDollars() %>">
    <input type="hidden" name="totalPrevMargins" value="<%= quotationForm.getTotalPrevMargins() %>">
    <input type="hidden" name="marginReason" value="<%= quotationForm.getMarginReason() %>">
    <input type="hidden" name="prevQuotationNo" value="<%= quotationForm.getPrevQuotationNo() %>">
    <input type="hidden" name="customerName" value='<%= ( quotationForm.getCustomerName() == null ) ? "" : quotationForm.getCustomerName() %>' >
    <input type="hidden" name="customerId" value="<%= quotationForm.getCustomerId() %>" >
    <input type="hidden" name="billingAddressId" value='<%= quotationForm.getBillingAddressId() %>' >
    <input type="hidden" name="shippingMethodName" value='<%= ( quotationForm.getShippingMethodName() == null ) ? "" : quotationForm.getShippingMethodName() %>' >
    <input type="hidden" name="quotationDate" value='<%= ( quotationForm.getQuotationDate() == null ) ? "" : quotationForm.getQuotationDate()%>' >
    <input type="hidden" name="noofitems" value="<bean:write name="LineItem" property="lineItemNo" />">
    <input type="hidden" name="isSample" value="<%=request.getParameter("isSample")%>">
    <input type="hidden" name="action" value="">
	<input type="hidden" name="shipAccount1" value="<%=request.getAttribute("Method")%>"/>
    <input type="hidden" name="distributor" value="<%= quotationForm.isDistributor() %>">
    <input type="hidden" name="competatior1PriceUnitsType" value="<%= quotationForm.getCompetatior1PriceUnitsType() %>">
    <input type="hidden" name="competatior1PriceUnitOthers" value="<%= quotationForm.getCompetatior1PriceUnitOthers() %>">
    <input type="hidden" name="competatior2PriceUnitsType" value="<%= quotationForm.getCompetatior2PriceUnitsType() %>">
    <input type="hidden" name="competatior2PriceUnitOthers" value="<%= quotationForm.getCompetatior2PriceUnitOthers() %>">
    <input type="hidden" name="rebateTargetGoalTimeFrame" value="<%= quotationForm.getRebateTargetGoalTimeFrame() %>">
    <input type="hidden" name="rebateTargetGoalTimeFrameOthers" value="<%= quotationForm.getRebateTargetGoalTimeFrameOthers() %>">

</html:form>
</html:html>
<%-- till here --%>

<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>


<%-- Footer starts here --%>

<%@ include file="/jsp/includes/footer.jsp" %>

<%-- footer end here --%>

<%
        if ( "false".equalsIgnoreCase((String)request.getAttribute("otherstateadded")) ) { %>
      	<script language="javascript">
      		addNewSalesTaxType(document.QuotationForm.salesTaxType);
      		document.QuotationForm.newSalesState.value = "<%=request.getAttribute("newsalesstate") %>"
      		document.QuotationForm.newSalesTax.value = "<%=request.getAttribute("newsalesvalue") %>"
      	</script>
<% }%>
<script language="javascript">

var no = <%=i%>;

</script>



 <script language="javascript">
 function checkValidity(field)
 {
    var field_vlaue = "";
    var field_focus = "";

    if(field == 'Contact Person') {
        field_vlaue = document.QuotationForm.contactPerson.value;
        field_focus = "contactPerson";
    }

    if(field == 'Sales Person') {
        field_vlaue = document.QuotationForm.salesPerson.value;
        field_focus = "salesPerson";
    }

    if(field == 'Regional Rep'){
        field_vlaue = document.QuotationForm.regionalRep.value;
        field_focus = "regionalRep";
    }

    if(field == 'End User'){
        field_vlaue = document.QuotationForm.endUser.value;
        field_focus = "endUser";
    }

    var pa=document.getElementById("errors");
    pa.innerHTML = "";

    for(i=0;i<field_vlaue.length;i++)
	{
			var str = field_vlaue.charAt(i)
            if ( (str == "$") || (str == "#") || (str == "(") || (str == ")") )
			{
      		  var errMsg = "* " + field +" can not contain #,$,(, and )  Characters";
              pa.innerHTML = errMsg;
              var obj = eval("document.QuotationForm."+field_focus);
              obj.focus();
              return false;
			}
	}
 }

 //Added by Rohan on August 14th 2003 for allowing spaces in customer PO number
function checkCustomerPONumber(field)
 {
    var field_vlaue = document.QuotationForm.customerPO.value;
    var field_focus = "customerPO";
    var pa=document.getElementById("errors");
    pa.innerHTML = "&nbsp;";

    for(i=0;i<field_vlaue.length;i++)
	{
			var str = field_vlaue.charAt(i)
            if(i==0 && str==" ")
            {
                var errMsg = "* " + field +" can not start with a space";
                pa.innerHTML = errMsg;
                var obj = eval("document.QuotationForm."+field_focus);
                obj.focus();
                return false;
            }
            if ((str == "$") || (str == "#") || (str == "(") || (str == ")") || (str == "&") || (str == ".") || (str == ","))
			{
      		  var errMsg = "* " + field +" can not contain # $ ( ) . , and &";
              pa.innerHTML = errMsg;
              var obj = eval("document.QuotationForm."+field_focus);
              obj.focus();
              return false;
			}
	}
 }
//End of additions by Rohan on August 14th 2003

 function checkShipping(field)
 {
    var field_vlaue = "";
    var field_focus = "";

    if(field == 'Shipping Account') {
        field_vlaue = document.QuotationForm.shippingAccount.value;
        field_focus = "shippingAccount";
    }

    if(field == 'New Shipping Method') {
        field_vlaue = document.QuotationForm.newshippingMethod.value;
        field_focus = "newshippingMethod";
    }

    if(field == 'New Shipping Account'){
        field_vlaue = document.QuotationForm.newshippingAccount.value;
        field_focus = "newshippingAccount";
    }

    var pa=document.getElementById("errors");
    pa.innerHTML = "";

    for(i=0;i<field_vlaue.length;i++)
	{
			var str = field_vlaue.charAt(i)
            if ( (str == "$") || (str == "#") || (str == "(") || (str == ")") || (str == "&") || (str == ".") || (str == ",") )
			{
      		  var errMsg = "* " + field +" can not contain # $ ( ) . , and & Characters";
              pa.innerHTML = errMsg;
              var obj = eval("document.QuotationForm."+field_focus);
              obj.focus();
              return false;
			}
	}
 }

 function checkForDot(field)
 {
    var field_vlaue = document.QuotationForm.shippingTerms.value;
    var pa=document.getElementById("errors");
    pa.innerHTML = "";

    for(i=0;i<field_vlaue.length;i++)
	{
			var str = field_vlaue.charAt(i)
            if ( (str == ".") )
			{
    		  var errMsg = "* " + field +" can not contain . Character";
              pa.innerHTML = errMsg;
              document.QuotationForm.shippingTerms.focus();
              return false;
			}
	}
 }

 function checkForBraces(field)
 {
    var field_vlaue = document.QuotationForm.deliveryTerms.value;
    var pa=document.getElementById("errors");
    pa.innerHTML = "";

    for(i=0;i<field_vlaue.length;i++)
	{
        var str = field_vlaue.charAt(i)
        if ( (str == "(") || (str == ")") )
        {
          var errMsg = "* " + field +" can not contain '(' and ')' Characters";
          pa.innerHTML = errMsg;
          document.QuotationForm.deliveryTerms.focus();
          return false;
        }
	}
 }

 </script>
</BODY>
</HTML>
<%--
<%
    }
    catch( Exception e)
    {
        e.printStackTrace();
    }
%>
--%>
